Delete Redundant Records to Trash Can Directories

JFrog REST APIs

Products
JFrog Xray
Content Type
REST API
ft:sourceType
Paligo

Description: This REST API is called to delete redundant records to Trash Can directories. The redundant metadata of a Trash Can directory slows down the Small Garbage Collection process and can eventually cause an overall degradation in database performance. Calling this API alleviates this problem.

Note

The process of deleting redundant records to Trash Can directories needs to be performed only once and no more. Performing this process more than once will cause no damage but simply has no effect.

Security: Requires an admin user.

Produces: application/json

Usage:

curl -u <user_name>:<password> -XPOST http://artifactory_host:port/artifactory/api/deleteDirectoryTrashProperty/start

Since: 7.75

Sample Usage:

curl -u admin:password -XPOST http://artifactory_host:port/artifactory/api/deleteDirectoryTrashProperty/start \
-H "Content-Type: application/json" \
-d '{
  "batchSize":"10000",
  "pauseBetweenBatchesMs":"1000",
  "batchesCount":"-1"
}'

Query Parameters:

Field

Type

Description

batchSize

number

Optional parameter. Default value: 1000.

The number of records to retrieve for a single DB query, should be an integer greater than 0.

pauseBetweenBatchesMs

number

Optional parameter. Default value: 1000.

This parameter defines the pause (in milliseconds) between successive DB query executions. Should be an integer greater than 0.

batchesCount

number

Optional parameter. Default value: -1 (no limit).

This parameter limits the maximum number of DB query executions. For example, if batchesCount = 20 and batchSize is 1,000, then a maximum of (20 * 1,000) = 20,000 records can be deleted.

Note

If a positive value is set for this parameter, you may need to call this API more than once until all redundant records are deleted. Review the process logs (described below) to determine if all redundant records have been deleted.

Sample Response:

HTTP/1.1 202 Accepted
Content-Type: application/json
{
  "info": "Remove Directories Trashcan Time task has been submitted"
}

Process Logs for Deleting Redundant Records to Trash Can Directories

You can monitor how the deletion task is progressing by reviewing the process logs. During the removal process, log entries (at INFO level) are issued that can be used to follow the removal process. In the example below, the removal process is run with batchSize = 45 and pauseBetweenBatchesMs = 5000. As a result, 45*11 + 4 = 499 records were removed in 12 iterations, with 5 seconds between each interval.

023-11-14T13:21:26.850Z [jfrt ] [INFO ] [38b4da85c8ffe560]
[moveDirsTrashcanTimeService:31] [8ffe560|art-exec-186] - Batch #0 finished. 45 records were removed
2023-11-14T13:21:32.322Z [jfrt ] [INFO ] [38b4da85c8ffe560] 
[moveDirsTrashcanTimeService:31] [8ffe560|art-exec-186] - Batch #1 finished. 45 records were removed
[moveDirsTrashcanTimeService:31] [8ffe560|art-exec-186] - Batch #2 finished. 45 records were removed

...

2023-11-14T13:22:24.611Z [jfrt ] [INFO ] [38b4da85c8ffe560] 
[moveDirsTrashcanTimeService:31] [8ffe560|art-exec-186] - Batch #10 finished. 45 records were removed
2023-11-14T13:22:30.229Z [jfrt ] [INFO ] [38b4da85c8ffe560] 
[moveDirsTrashcanTimeService:31] [8ffe560|art-exec-186] - Batch #11 finished. 4 records were removed
2023-11-14T13:22:30.229Z [jfrt ] [INFO ] [38b4da85c8ffe560] 
[moveDirsTrashcanTimeService:33] [8ffe560|art-exec-186] - Last batch reached. 
Remove Directories Trashcan Time task finishes

When the process has completed and the maximum number of batch executions is reached, the following output is received:

2023-11-21T13:06:51.948Z [jfrt ] [INFO ] [4c06f1666671fb9 ] 
[DirsTrashcanTimeServiceImpl:31] [6671fb9|art-exec-452] - Max number (10) of batch executions reached. 
Remove Directories Trashcan Time task finishes