Skip to content

cmd: fix fast-path modtime parsing in cleanupStaleUploadsOnDisk - #236

Merged
Vonng merged 3 commits into
pgsty:mainfrom
clown15:fix-cleanup-stale-uploads-modtime
Oct 15, 2026
Merged

Vonng merged 3 commits into
pgsty:mainfrom
clown15:fix-cleanup-stale-uploads-modtime

Conversation

@clown15

@clown15 clown15 commented Oct 15, 2026 •

Copy link
Copy Markdown

Problem

Multipart upload directories on disk use plaintext <UUID>x<UnixNano>. Cleanup previously tried to decode them as Base64 before extracting the timestamp, so it fell back to reading local xl.meta unnecessarily. Plaintext directory names are themselves valid Base64 in common cases, and decoded bytes can even contain x; successful decoding is not a format discriminator.

Change

Parse the native directory name first with the existing multipartUploadTime() validator. Only then try the previous Base64 compatibility parser. Legacy or unrecognized names retain the metadata fallback, and failed metadata reads leave those uploads alone.

The fix reduces local metadata reads and deserialization during stale-upload cleanup. Cleanup settings remain configurable, with a 24-hour default expiry and a 6-hour default scan interval. Storage layouts and S3 upload IDs are unchanged.

Validation

  • Parser tests cover native IDs, a fixed Base64-collision UUID, legacy UUIDs, encoded IDs with and without a deployment prefix, malformed UUIDs, invalid/overflowing timestamps and empty input.
  • Cleanup tests assert actual ReadVersion counts, preservation of recent uploads, removal of expired uploads, legacy fallback and conservative handling of missing metadata.
  • Focused upload/completion regressions, targeted race tests, make verifiers and make build pass locally on Go 1.27.2.
  • Restoring the original PR parser makes the collision and malformed-directory regressions fail, confirming that the added tests cover the corrected behavior.

clown15 and others added 3 commits October 14, 2026 08:55
Upload ID directories on disk are named as '<UUID>x<UnixNano>'.
Attempting to decode them as Base64 fails unconditionally, causing
the cleanup routine to bypass the timestamp check and fall back to
disk.ReadVersion on every active upload.

Directly parse the timestamp suffix from the plaintext directory
name to restore O(1) stale upload detection, while preserving Base64
decoding and ReadVersion fallback for legacy uploads.

Signed-off-by: clown15 <[email protected]>
@Vonng
Vonng merged commit a7370aa into pgsty:main Oct 15, 2026
8 checks passed
@Vonng Vonng added this to the 20261018 milestone Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants