Skip to content

fix: order value-less replicated Object Lock updates by timestamp - #129

Merged
Vonng merged 1 commit into
mainfrom
fix/issue-111-object-lock-replica-ordering
Sep 6, 2026
Merged

Vonng merged 1 commit into
mainfrom
fix/issue-111-object-lock-replica-ordering

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

CopyObjectHandler stripped the Object Lock value keys and rebuilt them only inside retentionMode.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 incoming ON/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 fix f4c1286c9 repaired only the nonempty cases. AWS documents an empty Retention as 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?

GOWORK=off go test -tags kqueue,dev ./cmd -count=1 -v -run '^(TestAPICopyObjectReplicaAbsentLockFieldsPreserveNewerState|TestAPICopyObjectReplicaRetentionRemovalKeepsOrderingTimestamp|TestAPICopyObjectReplicaObjectLockOrdering|TestAPICopyObjectMarkerOnlyLeavesObjectLockUnchanged|TestAPICopyObjectReplicaLegalHoldTimestamp)$'

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. TestAPICopyObjectReplicaLegalHoldTimestamp and the neighbouring CopyObject tests stay green. gofmt clean, go vet clean, 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

  • 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 c4373ef29, 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 (release fix note)

🤖 Generated with Claude Code

https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe

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]>
@Vonng
Vonng merged commit 885ca60 into main Sep 6, 2026
8 checks passed
@Vonng
Vonng deleted the fix/issue-111-object-lock-replica-ordering branch September 9, 2026 11:42
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.

[P1] Empty Object Lock replication updates bypass ordering and erase newer object state

1 participant