Skip to content

fix: stop re-replicating an object whose retention was removed - #131

Merged
Vonng merged 2 commits into
mainfrom
fix/issue-117-lock-resend-compare
Sep 6, 2026
Merged

Vonng merged 2 commits into
mainfrom
fix/issue-117-lock-resend-compare

Conversation

@Vonng

@Vonng Vonng commented Sep 5, 2026

Copy link
Copy Markdown
Member

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-by trailer.

Description

getReplicationAction compared the source's stored metadata, where a removed retention is a present key with an empty value, against the target's HEAD headers, which never carry those keys (two filters strip an empty or invalid Object Lock value from GET/HEAD responses). The reflect.DeepEqual therefore always differed and the "already in sync" short circuit was dead for these versions, so every re-evaluation re-copied their metadata. Empty x-amz-object-lock-mode / x-amz-object-lock-retain-until-date are now skipped on both sides of the comparison, so absent and present-empty compare equal.

A comparison-only change is not safe on its own, which the adversarial review established: a target whose replication credential lacks s3:GetObjectRetention returns a HEAD with no retention even when it still holds one, so treating "no retention in HEAD" as in-sync would silently drop a real removal. The fix therefore confirms with the destination before skipping a removal: replicationActionForTarget issues a GetObjectRetention on that narrow path only, and treats only NoSuchObjectLockConfiguration or a successful nil/empty mode as confirmed-absent; any ambiguous response (a denied read, an unrecognised mode, or InvalidRequest, which a destination also emits when its own lock-config read fails) is uncertain and the removal is resent exactly as today. The deliberate null-version resync exclusion is preserved via an extracted, byte-identical predicate.

Fixes #117. Issue and plan: #117. Adversarial Codex review of this implementation: rounds 1-3 FAIL (each surfaced a distinct way a permission-filtered or error HEAD could be misread as confirmed-absent), round 4 PASS after every case was closed.

Motivation and Context

Inherited from upstream (getReplicationAction is byte-identical to upstream/master). A removed-retention object was re-sent on every scanner heal, existing-object pass and mc replicate resync; against a lock-disabled destination the resend also failed rather than settling. AWS documents an empty Retention as the way to drop retention on a GOVERNANCE object, so the empty stored value is the expected shape.

How to test this PR?

GOWORK=off go test -tags kqueue,dev ./cmd -count=1 -v -run '^(TestGetReplicationActionEmptyObjectLockValues|TestRetentionRemovedAtSource|TestTargetRetentionConfirmedAbsent|TestReplicationActionForTargetRetentionRemoval|TestReplicationActionForTargetNullVersionResync|TestEmptyRetentionValuesAreOmittedFromObjectResponseHeaders)$'

The eight-case comparison table is red on cases 2 and 3 (present-empty removal on either side) before the fix and green after; further tests cover the permission-filtered HEAD being treated as uncertain, the InvalidRequest lock-config-read ambiguity, the null-version exclusion, and that the target genuinely cannot emit empty lock keys. TestReplicationResync, TestReplicatedInfos, TestParseReplicateDecision, TestCompositeReplicationStatus and TestAPICopyObjectReplicaLegalHoldTimestamp stay green. gofmt clean, go vet clean, golangci-lint 0 issues.

Compatibility impact

No API, wire, storage, config or metrics change. The fix adds a conditional GetObjectRetention to the destination only on the ambiguous removed-retention path, where a full metadata copy runs today, so it is strictly less work there. It becomes effective only when the replication target credential can read retention: granting s3:GetObjectRetention in the replication target policy is now load-bearing, and this should be noted in the replication docs on silo.pgsty.com. getReplicationAction now diverges from upstream master (recorded divergence). The issue's hope that a lock-disabled destination settles back to COMPLETED is explicitly not delivered; that case still resends and still fails, for the same reason the removal cannot be confirmed there.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • All commits are signed off (git commit -s) per the DCO
  • Fixes a regression (inherited from upstream, not a SILO regression)
  • Unit tests added/updated
  • make verifiers equivalent: gofmt clean, go vet clean, golangci-lint 0 issues on ./cmd/...
  • Relevant package tests pass
  • Compatibility and rollback impact documented
  • Internal documentation updated (code comments)
  • Public documentation update opened in pgsty/silo.pgsty.com (note the required s3:GetObjectRetention target permission)

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe

@Vonng

Vonng commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

Independent review: one P2 correction required before merge.

retentionRemovedAtSource at lines 1057–1064 recognizes only present-empty public keys. The merged #111 receiver and #134 can produce a timestamp-only removal tombstone. With an otherwise matching, permission-filtered destination HEAD, this form returns replicateNone without the new GetObjectRetention confirmation, silently dropping a needed removal.

The focused reproduction returns action="none" retention calls=0 where it should resend metadata and perform one confirmation. Details and acceptance are in #117. Recognizing both persisted representations is a bounded addition to the existing helper; the conditional confirmation itself is necessary and the existing comparison tests pass.

@Vonng
Vonng force-pushed the fix/issue-117-lock-resend-compare branch from 05ab4ca to 5069251 Compare September 6, 2026 04:15
@Vonng

Vonng commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

Update — timestamp-only tombstone recognized; Codex adversarial review PASS

Responding to the 2026-09-06 P2. retentionRemovedAtSource recognized only representation (1) of a removed retention (object-lock key present with an empty value), missing representation (2) that restoreRetention and the replica update path persist: the retention ordering timestamp present, with the mode and retain-until-date keys absent. For that shape the helper returned false, so replicationActionForTarget skipped the GetObjectRetention confirmation and replicateNone silently dropped a needed removal when the target HEAD hides retention behind a permission-filtered credential.

The helper now recognizes both representations; a present ordering timestamp paired with a non-empty mode is a retention that was set (not removed) and still returns false. Rebased onto current main. New tests cover both representations, the set/removed discriminator, and all three end-to-end decisions (AccessDenied → replicateMetadata, 1 confirmation — the Codex reference case; target holds GOVERNANCE → replicateMetadata, 1; NoSuchObjectLockConfiguration → replicateNone, 1), with a negative control proving the fix is load-bearing.

Codex Astra 6 (Max) adversarial review: VERDICT PASS (round 1, no actionable defect within the single-erasure-set scope). #111 supplies the timestamp-only persistence this recognizes; legal hold needs no analog.

Local: gofmt/go vet/go build clean, targeted tests green. CI runs on the pushed head.

@Vonng

Vonng commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

Independent round-2 verification: the previously reported P2 is fixed at 0192c73d850743d62cc1391537560b17e7adc583.

I reran the original regression with source metadata produced by applyReplicatedObjectLock, rather than constructing only present-empty keys. The timestamp-only tombstone now makes one GetObjectRetention confirmation and resends metadata on AccessDenied. The present/absent destination matrix and the non-empty-mode negative control pass. The bounded helper addition is sufficient and necessary for the representation gap; I found no new actionable issue in this change.

The combined #131/#132/#134/#138 candidate passed 152 targeted tests/subtests and 5,701 full cmd/internal tests/subtests (166 skipped). Product patches combine cleanly; the additive #131/#138 test-file conflict requires keeping both test groups and their imports. #117 is updated to verified/awaiting merge. No product correction was added by this review.

Vonng and others added 2 commits September 7, 2026 00:06
getReplicationAction builds its source map from oi1.UserDefined, where a
removed retention is a present key with an empty value, and its target map
from the destination's HEAD headers, which can never carry those keys because
setObjectHeaders skips empty lock values and FilterObjectLockMetadata drops
both keys when the mode is invalid. The comparison then always reports a
difference, the replicateNone fast path is dead for such versions, and an
otherwise matching version re-copies its metadata on every evaluation.

Skip an entry whose value is empty and whose key is x-amz-object-lock-mode or
x-amz-object-lock-retain-until-date, case-insensitively, in both comparison
loops, using the joined value on the target side. Normalizing only the source
would regress the case where both sides hold the empty pair.

HEAD also omits a real retention from a credential without
s3:GetObjectRetention, which the documented target policy does not grant, so
that normalization alone would read a destination hiding a retention as in
sync and drop the removal. replicationActionForTarget therefore confirms with
the destination before skipping the resend: only an explicit answer, no
retention on the version, clears it. Everything else keeps today's metadata
resend, including a denied or unreachable destination, a mode the SDK does not
recognize, and InvalidRequest, which names a bucket without Object Lock but is
also what a destination answers when its own read of that configuration fails.
The null version an existing object resync excludes is never reopened.

Tests: TestGetReplicationActionEmptyObjectLockValues (eight cases, red on 2
and 3 before this change), TestRetentionRemovedAtSource,
TestTargetRetentionConfirmedAbsent,
TestReplicationActionForTargetRetentionRemoval,
TestReplicationActionForTargetNullVersionResync and
TestEmptyRetentionValuesAreOmittedFromObjectResponseHeaders.
Compatibility: sender side only, no wire or storage change, so a fixed source
converges against any destination version.

Fixes #117

Signed-off-by: Feng Ruohang <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe
…ompare

retentionRemovedAtSource only recognized representation (1) of a removed
retention: the object lock key present with an empty value. But a removal
that arrived by replication persists representation (2): restoreRetention
(and the receiver's replica update path) writes only the retention ordering
timestamp when the mode is empty, leaving the mode and retain-until-date keys
absent. For that shape the helper returned false, so replicationActionForTarget
skipped the GetObjectRetention confirmation and let getReplicationAction's
replicateNone stand, silently dropping a needed removal when the destination
HEAD hides retention behind a permission-filtered credential.

Recognize representation (2) as well: a present retention ordering timestamp
with the mode value absent or empty is a removal. A present timestamp paired
with a non-empty mode is a retention that was set, not removed, and still
returns false.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe
Signed-off-by: Feng Ruohang <[email protected]>
@Vonng
Vonng force-pushed the fix/issue-117-lock-resend-compare branch from 0192c73 to 7935c84 Compare September 6, 2026 16:08
@Vonng
Vonng merged commit e27ba2b into main Sep 6, 2026
8 checks passed
@Vonng
Vonng deleted the fix/issue-117-lock-resend-compare branch September 6, 2026 16:22
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.

[P2] Retention-removal replication mishandles empty-value and timestamp-only state

1 participant