Repository navigation
fix: order value-less replicated Object Lock updates by timestamp - #129
Merged
Merged
Conversation
CopyObjectHandler rebuilt the destination metadata with the public Object Lock keys stripped (cmd/object-handlers.go:1708) and then restored a value only inside retentionMode.Valid() and legalHold.Status.Valid() (cmd/object-handlers.go:1715 and :1732), so a replica update that carried no retention or legal-hold value never reached the ordering comparison and silently erased whatever the destination held, however new it was; a retention removal that did win recorded no ordering timestamp either, so cmd/bucket-object-lock.go:370 later read an unparseable stored timestamp and let an older retained value back in. Each replica field is now decided on its source timestamp first and its incoming value second, and both restore helpers write the stored timestamp back before returning early on an empty stored value, which is the only way a removal timestamp survives the REPLACE metadata directive. Legal hold stays deliberately asymmetric: S3 has no legal-hold removal, an explicitly empty status is already rejected as invalid, and an absent status conveys no change even when an orphaned timestamp arrives with it, so only a valid ON or OFF can win. Three inherited defects would have defeated that ordering, so they are fixed here too. The SSE-KMS branch of putOptsFromHeaders built its own ObjectOptions and dropped the parsed lock timestamps, leaving every replicated lock update unordered on a bucket with default KMS encryption; it now carries them. The in-place SSE-C key rotation snapshots the stored reserved metadata into encMetadata before the lock decision exists and merges it back afterwards to preserve the encryption headers, reinstating the ordering timestamp the decision had just replaced; the snapshot is now reconciled with the decision for a trusted replica. Finally, the value-less handling applies only to an actual replica: a trusted peer that sends the replication marker without REPLICA status keeps the previous behaviour, so a REPLACE copy carrying no lock headers still writes a version with no retention and no hold. Tests: TestAPICopyObjectReplicaAbsentLockFieldsPreserveNewerState, TestAPICopyObjectReplicaRetentionRemovalKeepsOrderingTimestamp, TestAPICopyObjectReplicaObjectLockOrdering, TestAPICopyObjectReplicaRetentionRemovalUnderBucketKMS, TestAPICopyObjectReplicaLockTimestampSurvivesSSECKeyRotation and TestAPICopyObjectMarkerOnlyLeavesObjectLockUnchanged, all on ErasureSD and Erasure. Compatibility: no API, wire or stored-field change, and a field arriving with no source timestamp is unordered and now preserves destination state, so an un-upgraded 0806 peer keeps replicating safely while it still runs the old erasing receiver. Fixes #111 Signed-off-by: Feng Ruohang <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
3 tasks
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.
Contribution Licensing (no CLA, inbound=outbound, DCO required)
This project does not use a CLA; contributions are accepted inbound=outbound.
By submitting this pull request I represent that I have the right to contribute
the changes, which are licensed under this repository's
GNU Affero General Public License v3.0 or later
and remain my copyright. Every commit carries a DCO
Signed-off-bytrailer.Description
CopyObjectHandlerstripped the Object Lock value keys and rebuilt them only insideretentionMode.Valid()/legalHold.Status.Valid(), so a replica update whose source carried no value never reached the timestamp comparison and silently erased newer stored retention or legal hold; a retention removal also failed to persist its own ordering timestamp, letting a delayed older value reappear. The two blocks become switches keyed on the per-field source timestamp: a newer update applies, a newer removal clears the value and persists its timestamp, and a stale or unordered update restores the stored state. Legal hold requires a valid incomingON/OFF, since S3 has no hold removal. The restore helpers now write the stored timestamp ahead of their early return so a removal timestamp survives under the REPLACE metadata directive.Fixes #111. Fix plan agreed with the Codex reviewer: #111 (comment). Adversarial Codex review of this implementation: round 1 FAIL (three MAJOR), round 2 PASS.
Motivation and Context
An ordinary delayed or independent metadata update across active replication sites could remove a more recent retention or legal hold; S3 success responses hid the loss. Inherited from upstream
c4373ef29; the interval fixf4c1286c9repaired only the nonempty cases. AWS documents an emptyRetentionas the way to drop retention on a GOVERNANCE object, so the empty stored value is the expected shape and the comparison must tolerate it.How to test this PR?
The adopted repros and probes assert mode, retain-until date and timestamp together, on ErasureSD and Erasure, including present-empty removals, the REPLACE directive, an orphaned legal-hold timestamp, an SSE-KMS-default destination and a marker-only (non-replica) request; red on main, green with the fix.
TestAPICopyObjectReplicaLegalHoldTimestampand the neighbouring CopyObject tests stay green.gofmtclean,go vetclean, golangci-lint 0 issues.Compatibility impact
No API or wire change: the same headers are read, none added, no stored field changes meaning. Source timestamps are read only for a trusted replication peer, and an unparseable one is already a 400. Mixed-version replication converges node by node; an un-upgraded receiver keeps the old behaviour until it restarts. Objects already damaged by the bug are not repaired; re-apply the retention or hold at the source and it replicates normally.
Types of changes
Checklist:
git commit -s) per the DCOc4373ef29, not a SILO regression)make verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...pgsty/silo.pgsty.com(release fix note)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe