Repository navigation
fix: retransmit and re-order Object Lock for SSE-C replicas (single erasure set) - #134
Conversation
|
Independent review: changes required before merge. The real TLS two-site recovery test found a within-scope failure that the current signed-handler fixtures do not cover: a single-PUT SSE-C replica previously compressed by the destination still fails resync with Full reproduction, minimum fix constraints, and the current-main test integration failures are recorded in #120. Please resolve the merge conflict, the rebrand baseline failure, and the Also track #136: a completed resync's persisted counters can lag the final worker result until the one-minute flush. This is an inherited finalization race, not a reason to expand the SSE-C write fix into a multi-pool redesign. Keep the existing #133 boundary explicit. |
9e39aad to
79da38f
Compare
Rebased onto current main. #119 made PutObjectPart derive an encrypted part's plaintext length and reject a part that cannot be a valid sio stream, so TestReplicaLockReconcileNullVersion's completeNullMPU fixture (a 4-byte plaintext part under SSE-C metadata) no longer stores; build it with sio.Encrypt like the other encrypted-part fixtures. Also regenerate the rebrand-guard baseline for the replication SSE header the retransmit path reintroduces (headers 84 -> 85). Mechanical integration only. Signed-off-by: Feng Ruohang <[email protected]>
PutObjectHandler's precondition callback ran DecryptObjectInfo on the stored object before checkPreconditionsPUT, so an authenticated raw SSE-C replica overwrite was rejected when the stored version could not decrypt. A replica a pre-fix destination (issue #109) left as compress(ciphertext) or a re-encrypted body has an invalid decrypted length, so DecryptObjectInfo returned errObjectTampered and the retransmission that repairs it never ran -- the version stayed damaged through resync. #134's raw-replica exemption only covered the version/ETag duplicate check inside checkPreconditionsPUT, one step too late. Skip the stored object's decryption precondition for an authenticated raw SSE-C replica write, keyed on the incoming request's restored SSE-C metadata, the same predicate checkPreconditionsPUT already uses. The overwrite fully replaces the object, so requiring the damaged stored version to decrypt is both wrong and unnecessary; ordinary writes, If-Match/If-None-Match, and non-SSE-C replicas keep the check. Adds a red/green regression: a raw retransmit over a version staged as an undecodable body returns 500 XMinioObjectTampered before this change and 200 with full customer-key recovery after. Fixes the single-PUT compression-damage recovery gap in #120. Signed-off-by: Feng Ruohang <[email protected]>
PutObjectHandler's precondition callback ran DecryptObjectInfo on the stored object before checkPreconditionsPUT, so an authenticated raw SSE-C replica overwrite was rejected when the stored version could not decrypt. A replica a pre-fix destination (issue #109) left as compress(ciphertext) or a re-encrypted body has an invalid decrypted length, so DecryptObjectInfo returned errObjectTampered and the retransmission that repairs it never ran -- the version stayed damaged through resync. #134's raw-replica exemption only covered the version/ETag duplicate check inside checkPreconditionsPUT, one step too late. Skip the stored object's decryption precondition only for a PURE raw SSE-C replica overwrite (a trusted SSE-C replica write with no public precondition), keyed on the incoming request's restored SSE-C metadata, the same predicate checkPreconditionsPUT uses. Such a write fully replaces the object, so requiring the damaged stored version to decrypt is both wrong and unnecessary. A conditional request keeps the check: DecryptObjectInfo also normalizes the stored sealed ETag to the client-visible one, and If-Match/If-None-Match must compare against that, not the sealed ETag -- skipping it for every replica inverted both conditions. Ordinary writes and non-SSE-C replicas are unchanged. Adds red/green regressions: a raw retransmit over a version staged as an undecodable body returns 500 XMinioObjectTampered before this change and 200 with full customer-key recovery after; and a conditional replica PUT (If-Match / If-None-Match) on the client-visible ETag is honoured rather than inverted. Fixes the single-PUT compression-damage recovery gap in Signed-off-by: Feng Ruohang <[email protected]> #120.
79da38f to
79ca365
Compare
Update — rebased, P1 + round-2 P2 fixed, Codex adversarial review PASSResponding to the 2026-09-06 review that found this PR insufficient (P1 recovery gap) and the round-2 finding. Rebased onto current P1 (undecodable-replica recovery) — fixed. P2 (round 2, Codex-found) — fixed. The skip was initially too broad: with Codex Astra 6 (Max) adversarial review: 2 rounds → VERDICT PASS. Confirmed the end-to-end recovery, no new unauthenticated/untrusted/non-SSE-C bypass, size handling unaffected, and non-vacuous regressions. Scope is a single erasure set; multi-pool remains tracked in #133. Local: |
|
Independent round-2 verification: the previously reported within-scope P1 recovery defect is fixed at A fresh real two-site TLS test recreated damage using the published 20260903 binary, then upgraded destination before source on the same data and VersionIDs. The integrated candidate now repairs all previously failing cases:
All four preserve the original destination VersionID, reject the wrong customer key, and accept a later tag update with correct data. The explicit conditional-request, commit-time Object Lock, and null-version fixtures pass. The previous merge conflict, invalid four-byte encrypted fixture, and rebrand baseline failure are resolved. The combined candidate passes the rebrand guard, 5,701 cmd/internal tests/subtests (166 skipped), and 16 targeted race tests/subtests. A separate release-accounting caveat remains: #139. After a previously healthy destination rejects a new SSE-C update with |
The resync worker classified each object by whether the target version merely existed (a tgt.StatObject HEAD), ignoring the outcome of the replicateObject/replicateDelete call it had just made. A quota-rejected update leaves the old version in place, so StatObject succeeded and the resync recorded a false success - reported as Completed / N success / 0 failed and persisted across restart (issue #139). #134's SSE-C HEAD marker made StatObject succeed for SSE-C too, exposing it there. The delete path had the mirror flaw (a failed delete leaves the object, so the HEAD succeeded), and FailedSize was never incremented (a failed 196,608-byte object counted as 1 failed / 0 bytes). replicateObject and replicateDelete already build the per-target replicatedInfos (each replicatedTargetInfo carries Arn, ReplicationStatus and Err) but discarded it. Return it (callers that only trigger replication ignore the value - a Go call statement discards it, so the queue paths are unchanged) and classify the resync from the target whose Arn == opts.arn via a small pure helper: - Completed without error -> replicated (+ that target's size, falling back to the object size). - Failed or errored -> failed (+ the object size, fixing FailedSize). - opts.arn absent from the result (not attempted) -> failed; a resync that cannot confirm the object reached the target is not a success. The StatObject-existence block (including the delete-marker/MethodNotAllowed special case, now subsumed by the delete outcome) is removed. #134's SSE-C HEAD marker is left intact - it is needed for genuine SSE-C success. Adds a table-driven regression for the classifier covering a completed update, a failed update over an existing version, an errored-but-Completed result, a delete failure, a delete-marker success (zero bytes) and an un-attempted ARN. Classifying by existence makes the failed cases count success and fails the test. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
The resync worker classified each object by whether the target version merely existed (a tgt.StatObject HEAD), ignoring the outcome of the replicateObject/replicateDelete call it had just made. A quota-rejected update leaves the old version in place, so StatObject succeeded and the resync recorded a false success - reported as Completed / N success / 0 failed and persisted across restart (issue #139). #134's SSE-C HEAD marker made StatObject succeed for SSE-C too, exposing it there. The delete path had the mirror flaw (a failed delete leaves the object, so the HEAD succeeded), and FailedSize was never incremented (a failed 196,608-byte object counted as 1 failed / 0 bytes). replicateObject and replicateDelete already build the per-target replicatedInfos (each replicatedTargetInfo carries Arn, ReplicationStatus and Err) but discarded it. Return it (callers that only trigger replication ignore the value - a Go call statement discards it, so the queue paths are unchanged) and classify the resync from the target whose Arn == opts.arn via a small pure helper: - Completed without error -> replicated (+ that target's size, falling back to the object size). - Failed or errored -> failed (+ the object size, fixing FailedSize). - opts.arn absent from the result (not attempted) -> failed; a resync that cannot confirm the object reached the target is not a success. The StatObject-existence block (including the delete-marker/MethodNotAllowed special case, now subsumed by the delete outcome) is removed. #134's SSE-C HEAD marker is left intact - it is needed for genuine SSE-C success. Adds a table-driven regression for the classifier covering a completed update, a failed update over an existing version, an errored-but-Completed result, a delete failure, a delete-marker success (zero bytes) and an un-attempted ARN. Classifying by existence makes the failed cases count success and fails the test. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
The replication sender's target HEAD carries no SSE-C customer key, so for an SSE-C object the target answers 400 and replicateAll fell into a metadata-only CopyObject that fails on any non-empty SSE-C object (the undecryptable source checksum makes the target recompute one and rewrite the data with a plaintext-sized reader). Once a non-empty SSE-C replica existed, tag, retention and legal-hold changes never reached it, a heal never retransmitted, and a resync neither repaired the replica nor counted it correctly. Forcing a full retransmit alone was not enough: checkPreconditionsPUT rejects a write whose PreserveETag and VersionID match the stored version, only the single-part sealed ETag is truncated before that comparison, so a multipart SSE-C retransmit answered 412, which the sender turns into success. Inherited from upstream ad04afe. Select replicateAll when the SSE-C HEAD cannot answer (the two previous assignments were dead: rAction still forced the metadata path), exempt an authenticated replica write that carries an SSE-C seal from the duplicate version and ETag rejection (the predicate is the incoming write's restored SSE-C metadata, not what the destination holds), and send the internal replication marker on the resync accounting HEAD for SSE-C objects so a peer answers with the replica metadata instead of 400. Tests: TestAPISSECReplicaRetransmitOverExistingVersion (multipart replica initiation over the same version and ETag answered 412 on main, now 200 with parts sent and plaintext readback; single-part and zero-byte writes unchanged), TestAPISSECReplicaWriteExemptionIsKeyedOnTheIncomingWrite (plaintext replica over an SSE-C version still 412; SSE-C replica over a plaintext version exempted and readable), and TestAPISSECReplicationTargetHead (keyless HEAD 400, missing key 404, marked HEAD 200 with metadata, metadata CopyObject ExcessData on a non-empty object) on ErasureSD and Erasure. Compatibility: every update of an SSE-C object now retransmits its bytes; a peer that rejects the internal marker fails the accounting HEAD as before; the #109 destination fix must be deployed first or a retransmitted replica is transformed again. Fixes #120 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
…rasure set) Issue #120 routes an existing SSE-C replica through PutObjectHandler and NewMultipartUploadHandler. On main those handlers assigned the incoming retention and legal hold directly, without the source-timestamp ordering #111 added to CopyObjectHandler and without persisting the ordering timestamps, so in active-active replication a retransmit carrying an older value could overwrite a destination version's newer lock state. Share #111's ordering decision as applyReplicatedObjectLock in cmd/bucket-object-lock.go and call it from CopyObject, PUT and multipart initiation. A request that is not an actual trusted replica keeps ordinary write semantics (a validated value is applied and stamped now); only a real replica update is ordered against the stored version, so a marker-only peer write no longer drops a validated hold or default retention. CopyObject keeps its SSE-C key-rotation encMetadata reconciliation inline. putReplicationOpts now emits a stored retention ordering timestamp even when the value keys are absent, so a removal recorded on the retransmit PUT path still replicates onward. replicateAll marks Failed and carries the error when putReplicationOpts fails. The handler decision is made against the version as it stands then, which a concurrent lock update can outrun before the write commits, and for multipart across the whole initiation-to-completion span. Close that window under the object write lock the receiving erasure set holds: a trusted SSE-C replica full write sets ObjectOptions.ReplicaLockReconcile, and erasureObjects.PutObject and CompleteMultipartUpload re-run the ordering (reconcileStoredObjectLock, which orders retention and legal hold independently by their reserved timestamps) against the destination version read on that set before committing. Persisted upload metadata records the null version as an empty VersionID, so completion looks that up as the null version rather than the latest. The reconcile runs only against an existing version; a not-found destination keeps the write's own accepted lock, including a pre-upgrade upload that persisted values without ordering timestamps, and a non-not-found read error fails the write. Scoped to the SSE-C paths this issue enables; CopyObject is left as #111 wrote it. Scope: this orders Object Lock against the destination version under the write lock and is correct for a single erasure set. A multi-pool deployment -- where a version can have duplicate copies across pools, object ModTime ties do not track per-field lock timestamps, and the object namespace lock is per-pool -- needs a cross-pool lock-safe reconcile and is deliberately out of scope here, tracked in pgsty/silo#TBD-multipool-lock. Tests: TestAPISSECReplicaRetransmitObjectLockOrdering and its multipart sibling; TestAPIReplicaMultipartNewerHoldSurvivesCompletion and TestReplicaPutObjectLockReconcileUnderWriteLock (a hold or retention reaching the version after the handler decision, or after multipart initiation, survives the commit; a pre-upgrade upload on an absent version keeps its lock); TestReplicaLockReconcileNullVersion (a null-version completion reconciles the null version, not a coexisting UUID version, and an absent null version keeps its accepted lock); TestAPIReplicaMarkerOnlyAppliesObjectLock; TestReplicaStoredLock; the timestamp-only putReplicationOpts round trip; and the retransmit, exemption and target-head tests. The #111 CopyObject replica suite and the existing #120 suite stay green, as do the PUT/multipart handler and object-layer regression suites. Compatibility: the shared helper preserves #111's CopyObject behavior; a non-replica PUT or multipart initiation that sets Object Lock now also stamps the reserved ordering timestamp, matching CopyObject since #111; only trusted SSE-C replica writes take the in-lock reconcile. Refs #120 Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
Fill the tracked-issue number into the scope comments of the single erasure set Object Lock reconcile added for SSE-C replica retransmit. No behaviour change. Refs #120 Refs #133 Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
Rebased onto current main. #119 made PutObjectPart derive an encrypted part's plaintext length and reject a part that cannot be a valid sio stream, so TestReplicaLockReconcileNullVersion's completeNullMPU fixture (a 4-byte plaintext part under SSE-C metadata) no longer stores; build it with sio.Encrypt like the other encrypted-part fixtures. Also regenerate the rebrand-guard baseline for the replication SSE header the retransmit path reintroduces (headers 84 -> 85). Mechanical integration only. Signed-off-by: Feng Ruohang <[email protected]>
PutObjectHandler's precondition callback ran DecryptObjectInfo on the stored object before checkPreconditionsPUT, so an authenticated raw SSE-C replica overwrite was rejected when the stored version could not decrypt. A replica a pre-fix destination (issue #109) left as compress(ciphertext) or a re-encrypted body has an invalid decrypted length, so DecryptObjectInfo returned errObjectTampered and the retransmission that repairs it never ran -- the version stayed damaged through resync. #134's raw-replica exemption only covered the version/ETag duplicate check inside checkPreconditionsPUT, one step too late. Skip the stored object's decryption precondition only for a PURE raw SSE-C replica overwrite (a trusted SSE-C replica write with no public precondition), keyed on the incoming request's restored SSE-C metadata, the same predicate checkPreconditionsPUT uses. Such a write fully replaces the object, so requiring the damaged stored version to decrypt is both wrong and unnecessary. A conditional request keeps the check: DecryptObjectInfo also normalizes the stored sealed ETag to the client-visible one, and If-Match/If-None-Match must compare against that, not the sealed ETag -- skipping it for every replica inverted both conditions. Ordinary writes and non-SSE-C replicas are unchanged. Adds red/green regressions: a raw retransmit over a version staged as an undecodable body returns 500 XMinioObjectTampered before this change and 200 with full customer-key recovery after; and a conditional replica PUT (If-Match / If-None-Match) on the client-visible ETag is honoured rather than inverted. Fixes the single-PUT compression-damage recovery gap in Signed-off-by: Feng Ruohang <[email protected]> #120.
79ca365 to
236e163
Compare
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
An existing SSE-C replica could not be updated or repaired: the replication sender's target HEAD is keyless, so for an SSE-C object it answers 400, and the sender fell into a metadata-only CopyObject that fails on any non-empty SSE-C object; a multipart retransmit was additionally swallowed by a 412 precondition. Tag, retention and legal-hold changes never reached such a replica, a heal never retransmitted, and resync neither repaired nor accounted for it.
This PR makes the retransmit work and keeps Object Lock correct for it, for a single erasure set (the default deployment):
replicateAllselects a full retransmit when the SSE-C HEAD cannot answer;putReplicationOptserrors reportFailed, not a phantomCompleted, and a removed retention is sent as a value-less update carrying its ordering timestamp.PutObjectandCompleteMultipartUploadre-read the addressed destination version on the receiving erasure set (an empty persisted multipart VersionID is normalised to the null version) and re-order the incoming retention/legal-hold against it per field by their ordering timestamps, honouring a stored removal; a genuinely absent version keeps the write's own accepted lock; a non-not-found read error fails the write. Marker-only and non-replica writes keep ordinary write semantics.Fixes #120. Plan agreed with the Codex reviewer: #120. Adversarial Codex review of this implementation: eight rounds. Rounds 1-3 established the ordering must survive a concurrent update; the maintainer authorised the commit-time write-lock merge; rounds 4-6 drove out its multi-pool gaps; the maintainer then narrowed the scope to a single erasure set with a tracked follow-up; round 7 caught a null-version lookup bug; round 8 PASS with no findings.
Scope and the multi-pool follow-up
This change is correct for a single erasure set (one server pool), where a version has exactly one authoritative copy. Making the reconcile authoritative across server pools — a shared pools-layer lock that also serialises with the metadata-mutation paths, per-field cross-pool timestamp resolution, and retiring the stale duplicate copy so reads select the reconciled version — is a general multi-pool replica-write concern, deliberately out of scope here and tracked in #133. The code comments and the
ReplicaLockReconciledoc point there.Motivation and Context
Inherited from upstream (
ad04afe38). AWS retrieves an SSE-C replica with the same customer key the source used, so the destination cannot compare or re-encrypt the body; a full retransmit is the only action that completes. Legal hold must never be silently dropped, which is why the ordering is done under the write lock.How to test this PR?
On a single erasure set: a multipart replica initiated with legal hold OFF@09:00 that completes after ON@10:00 reached the same version preserves ON (red before the in-lock reconcile, green after); the PUT interleave does the same; a null-version completion preserves the null version's own lock and leaves a coexisting UUID version untouched; the retransmit, exemption, target-head and retention-removal round-trip tests pass; the #111 suite and object-layer regressions stay green.
gofmt,go vet, golangci-lint clean.Compatibility impact
No wire or API change. Every update of an SSE-C object now retransmits its bytes. The exemption and the reconcile are gated to authenticated SSE-C replica writes; ordinary writes,
If-Match/If-None-Match, and non-SSE-C replicas are unchanged. Deploy the #109 destination fix (PR #122) first, or a retransmitted replica is transformed again. The multi-pool limitation is documented and tracked in #133. No recovery instruction for #109-damaged replicas is published until the bounded recovery check runs.Types of changes
Checklist:
git commit -s) per the DCOad04afe38, not a SILO regression)make verifiersequivalent: gofmt clean, go vet clean, golangci-lint 0 issues on./cmd/...pgsty/silo.pgsty.com(release fix note; replication docs after the recovery check)🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe