Repository navigation
fix: preserve bucket metadata across concurrent updates and reloads - #156
Merged
Merged
Conversation
Audit of the three deferred #105 follow-ups. Each reproduces with a deterministic red test in cmd/bucket-metadata-race_test.go, and each fix is the minimal change that turns its test green while preserving the <bucket>.lck -> metadata.lock -> .metadata.bin lock order established by #103. 1. Lifecycle expiry merge lost update (persistent). PeerBucketLCConfigHandler and healBucketILMExpiry read the current lifecycle with an unlocked GetConfigFromDisk, merged the replicated expiry rules with the local transition rules, then wrote the pre-computed blob via Update. Any lifecycle transition change committed between the merge read and the merge write was silently lost. New BucketMetadataSys.UpdateExpiryLCConfig performs the read, merge, and save under one metadata.lock; mergeExpiryWithLCConfig now takes the locked snapshot and validates object-lock retention from it instead of re-reading (avoids a re-entrant metadata load under the lock). 2. DeleteBucket ghost .metadata.bin (persistent). DeleteBucket took only <bucket>.lck while config writers take only metadata.lock, so a writer that was mid-save could re-create .metadata.bin after the prefix purge. The purge now runs under metadata.lock, with a best-effort unlocked fallback so a delete is never blocked from completing. 3. Overlapping peer reloads publishing a stale resident cache (freshness only; the persisted record stays correct). LoadBucketMetadataHandler and the GetConfig cache-miss path published with an unconditional Set, so a reload that read an older revision could overwrite a newer resident record until the next refresh. New BucketMetadataSys.setReloaded (and a matching GetConfig guard) refuses to regress a newer resident record, mirroring refreshBucketsMetadataLoop. Verification: go build -tags kqueue,dev ./...; go vet ./cmd; gofmt clean; rebrand-guard baseline unchanged; go test -tags kqueue,dev ./cmd (207s) green; new tests plus the #103 metadata suite green under -race. Refs #105. Parent #102. Foundation #103. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
…adata-merge-20260908 Signed-off-by: Feng Ruohang <[email protected]>
…-merge-20260908 Signed-off-by: Feng Ruohang <[email protected]>
Signed-off-by: Feng Ruohang <[email protected]>
Vonng
marked this pull request as ready for review
September 8, 2026 06:43
Signed-off-by: Feng Ruohang <[email protected]>
pull Bot
pushed a commit
to ShinnChow/silo
that referenced
this pull request
Sep 9, 2026
…gsty#105 T3) The pgsty#105 T3 change (PR pgsty#156) tried to keep the resident metadata cache monotonic by guarding peer-reload publication on lastUpdate(). But lastUpdate() is the max of per-config timestamps and cannot order whole records: a node caching {policy@20, CORS@10} that receives a newer CORS@15 still has lastUpdate()==20, so the guard rejects the legitimately-newer record and the periodic refresh (same comparator) cannot repair it. A paused reload could also resurrect deleted resident state. Per the maintainer decision, revert the reload publication to its original unconditional (acceptable-until-refresh) behavior: - remove setReloaded and restore the plain Set plus notification/target registry updates in LoadBucketMetadataHandler; - restore refreshBucketsMetadataLoop's own lastUpdate() staleness check and globalEventNotifier.set / globalBucketTargetSys.set publication; - restore the unconditional GetConfig cache-miss publication; - document the known freshness limitation at the reload site (the periodic refresh is best-effort and cannot repair an equal-maximum-timestamp divergence). The T1 lifecycle merge-under-lock (UpdateExpiryLCConfig) and both T2 fixes (DeleteBucket takes metadata.lock before deleting; saveMetadata and loadBucketMetadataParseUnderLock recheck physical bucket existence) are kept fully intact. Tests: - drop the T3 reproductions (overlapping-reload resident-cache test and the peer-reload-preserves-current-targets publication test); - add lockBucketMetadataAcquireHook, a nil-in-production atomic test hook in the shared metadata.lock path, so tests can deterministically observe a caller (notably DeleteBucket, whose lock is taken through its erasureServerPools receiver and is invisible to an injected object layer) reaching the lock; - rewrite the T2 delete-race ghost test to hold metadata.lock MID-SAVE (past saveMetadata's existence recheck) and synchronize on the delete's actual lock attempt via the hook, so it isolates the lock-before-delete fix: removing only DeleteBucket's metadata.lock (recheck kept) now fails it; - rewrite the cancellation test to observe the delete's actual lock attempt, then cancel and await its error while still holding the lock, so a scheduling-delayed delete stopped by the canceled context can no longer pass on a broken tree. Refs pgsty#105. Follows pgsty#156. Co-Authored-By: Claude Opus 4.8 <[email protected]> Signed-off-by: Feng Ruohang <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bucket deletion could purge metadata while a configuration writer was still saving it, and replicated lifecycle expiry merges could overwrite concurrent local transition changes. Acquire the existing metadata lock before deletion, reject lock failure before any destructive action, and check that the physical bucket still exists before a queued metadata save or migration proceeds.
Lifecycle expiry merging now reads, merges, and saves under that same lock, with peer notifications sent after unlocking. Peer reloads and periodic refresh publish the newest cached/disk revision and its notification and replication-target registries under the same local mutex, so a delayed reload cannot apply old targets after rejecting its old cache revision.
Validation: regressions first reproduced deletion on lock cancellation, metadata recreation by queued normal/expiry updates, and stale target publication through the actual peer handler. All pass after the correction, together with the existing metadata tests under
-race.make verifiersand a default server build pass; the optional standalonetyposbinary is not installed locally. Full Go CI and vulnerability checks run on this candidate.The original candidate commits and contributor authorship are retained. No API, configuration, or persisted metadata format changes. No release or deployment is included.
Fixes #105.