Critical Section Cleanup Tool

The FileCloud Critical Section Cleanup tool is available in FileCloud version 21.1 and later

After a move or copy operation for a large folder, the critical section is automatically released. However, if there is a server exception that interrupts regular FileCloud processing, a critical section record may remain and block other operations in the folder. 

Manual Cleanup

The Critical Section Cleanup tool is a CLI tool that guides you in manually searching for and deleting critical section records. You may indicate how old the records must be to be included in the search.

The tool is criticalsectioncleanup.php and is located in C:\xampp\htdocs\resources\tools\criticalsection.

To run the tool, in a command line, enter the following. Note that -h multitenant.site2-name.com is optional and indicates the hostname if you want to look at a host other then the default.
for Windows:

C:\xampp\php\php.exe C:\xampp\htdocs\resources\tools\criticalsection\criticalsectioncleanup.php -h multitenant.site2-name.com -d 0

for Linux:

php /var/www/html/resources/tools/criticalsection/criticalsectioncleanup.php -h multitenant.site2-name.com -d 0

Parameters:

-h [host] - (optional) - The hostname. Use this if you want to look at a host other than the default.
-d [#days]-  (optional)  Delete all records older than # days, for example, -d 0 means delete all records older than today; -d 10 means delete all records older than 10 days ago.


If you do not specify a value for -d, the response will appear similar to the following. Respond to the questions asked in the prompts, and specify the number in brackets when indicating which record you want to delete.

===================================================

===================================================

Looking at default host. Use option -h [HOST_NAME] to target other non default host.

>>> Please enter number of days to filter records. (e.g. 1 will fetch records older than 1 day. Leave empty to not filter by days)
>>>
>>> Please enter a partial or full FileCloud path to search critical section records. (Leave empty to not filter by path)
>>>
>>> Found 3 record(s)
>>>  ---- [1] /user0/folder1 ... 2021-03-31
>>>  ---- [2] /user0/folder2 ... 2021-03-31
>>>  ---- [3] /user0/folder3 ... 2021-03-31
>>> Do you want to select a record for removal? (Y/N):
>>> Y
>>> Please enter the number of record you want to delete:
>>> 1
>>> Deleted /user0/folder1
>>> Do you want to select a record for removal? (Y/N):
>>> Y
>>> Please enter the number of record you want to delete:
>>> 3
>>> Deleted /user0/folder3
>>> Do you want to select a record for removal? (Y/N):
>>> Y
>>> Please enter the number of record you want to delete:
>>> 2
>>> Deleted /user0/folder2
>>> Do you want to select a record for removal? (Y/N):
>>> N
>>> Exit command


If you specify a value for -d, the response will appear similar to the following. Respond Y to Do you want to delete all records? to confirm deletion of the records.

C:\xampp\htdocs\resources\tools\criticalsection> php criticalsectioncleanup.php -d 10
===================================================
### Critical Section Cleanup

**criticalsectioncleanup.php** allows searching for critical section records filtering by path
and remove records selecting from the result list.
The command prompts the user before any action, so can be safely run and then follow the prompt
messages.

#### Usage

php ./criticalsectioncleanup.php -h <site_url>'

[optional] site_url: full qualified site url of the site to be exported or to be import target (multitenant).
If not specified, default site is assumed.
===================================================

Looking at default host. Use option -h [HOST_NAME] to target other non default host.

>>> Found 2 record(s)
>>>  ---- [1] /user0/load/file2 ... 2022-11-18
>>>  ---- [2] /user0/load/fixedtree_local/file ... 2022-11-18
>>> Do you want to delete all records? (Y/N):

Note: If some critical section records have an expiry time which was set using a maximum PHP integer value, the tool may not delete the records because it does not evaluate them as older than the specified number of days.
A workaround is to enter a very large negative number of days so the tool selects and deletes those records, for example:

Looking at default host. Use option -h [HOST_NAME] to target other non default host.

>>> Please enter number of days to filter records. (e.g. 1 will fetch records older than 1 day. Leave empty to not filter by days)
>>> -9999999999999999999

Automatic removal of critical section entries

To configure FileCloud to automatically remove critical section entries older than 3 days:

  1. Open cloudconfig.php.
    • Windows Location : C:\xampp\htdocs\config\cloudconfig.php
    • Linux Location : /var/www/html/config/cloudconfig.php
  2. Add the following:

    define("TONIDOCLOUD_CRITICAL_SECTION_CLEANUP_DAYS", '3')

    :