@@ -41,7 +41,32 @@ const LOG_PROGRESS_INTERVAL = (
4141const USAGE = `
4242cleanupMpuOrphans.js
4343
44- This script cleans up orphaned multipart upload (MPU) data from S3 buckets.
44+ This script cleans up orphaned multipart upload (MPU) data and
45+ metadata from S3 buckets.
46+
47+ Context:
48+ There can be S3 metadata keys from internal MPU shadow buckets,
49+ possibly associated with orphaned RING objects, that are left
50+ behind in some rare cases of duplicate and concurrent "complete
51+ MPU" or "abort MPU" requests on the same MPU object. They take up
52+ storage space and may cause listing slowdowns, until they are
53+ manually removed.
54+
55+ Technically, orphaned parts are defined as part metadata which do
56+ not have a corresponding overview key with the same upload ID
57+ (overview keys are present for incomplete, but visible, MPUs).
58+
59+ Principle:
60+ This script takes care of cleaning up those orphaned parts data and
61+ metadata keys with a two-phase process for each target bucket:
62+
63+ - Discovery phase: builds a map of orphaned MPU upload IDs present
64+ in the bucket
65+
66+ - Cleanup phase: scans the bucket with a versioned listing,
67+ matches any completed MPU with their orphaned counterpart to
68+ detect used sproxyd keys, and only deletes the unused ones along
69+ with the orphaned metadata
4570
4671Usage:
4772 node cleanupMpuOrphans.js
@@ -59,6 +84,31 @@ Optional environment variables:
5984 TRACE: set to 1 to trace every request to bucketd and sproxyd
6085 LISTING_PAGE_SIZE: number of keys to list per listing request (default ${ DEFAULT_LISTING_PAGE_SIZE } )
6186 LOG_PROGRESS_INTERVAL: interval in seconds between progress update log lines (default ${ DEFAULT_LOG_PROGRESS_INTERVAL } )
87+
88+ Logs:
89+ Logs are output to stdout in JSON format using the standard
90+ werelogs formatting. The main log messages are:
91+
92+ starting discovery phase: scanning MPU shadow bucket
93+ logged at the beginning of the discovery phase for a given bucket
94+ orphaned MPU found
95+ logged during discovery phase for each orphaned MPU discovered
96+ discovery phase complete
97+ logged when the discovery phase has completed for a given bucket
98+ starting cleanup phase: scanning bucket
99+ logged at the beginning of the cleanup phase for a given bucket
100+ deleted orphaned sproxyd key
101+ [VERBOSE ONLY] logged for each orphaned sproxyd key deleted
102+ not deleting sproxyd key used by completed MPU
103+ [VERBOSE ONLY] logged for each orphaned sproxyd key still used, NOT deleted
104+ deleted orphaned part metadata
105+ [VERBOSE ONLY] logged for each orphaned part metadata key deleted
106+ cleanup phase complete
107+ logged when the cleanup phase has completed for a given bucket
108+ completed MPU orphan cleanup
109+ logged when cleanup is complete for all target buckets/RAFT sessions
110+ progress update
111+ logged every LOG_PROGRESS_INTERVAL with progress stats
62112` ;
63113
64114const log = new werelogs . Logger ( 's3utils:cleanupMpuOrphans' ) ;
0 commit comments