Repository navigation
fix: count resync success by replication outcome, not target existence - #140
Conversation
…unts resyncBucket could publish and persist a Completed resync status that did not actually cover every object, in two ways: 1. It joined only the producer workers before the deferred markStatus ran, not the goroutine that folds each worker result into the status, so a Completed status could omit the last object (or a failed object) until the periodic ~1m flush (issue #136). The same finalization also closed the result channel on early-return paths while workers were still in flight, risking a send-on-closed-channel panic and a lost result. 2. markStatus persists under its own background context, so if the parent context was cancelled during the drain - workers then return without sending their computed result - or a worker dropped a result on the resync-cancel signal, a bare Completed was still recorded with counts that no longer matched the objects seen. Fixes (count integrity only; the inherited cancellation deadlock, walker leak, and single-token routing are tracked as separate follow-ups): - Centralize shutdown in a resyncResults helper whose finish() stops the workers (closes inputs, waits for them to exit) before closing the result channel and waiting for the consumer to drain, then lets the deferred markStatus persist the final counts. finish() now runs on every exit path. - Record a dropped result via sendResyncResult (a worker consuming the resync-cancel token returns without sending), and in the finalizer downgrade a Completed status to Failed via finalResyncStatus when the parent context was cancelled or a worker aborted - so a persisted Completed never misrepresents an incomplete resync. Deterministic tests: an on-disk round-trip of the terminal status (complete counts stay Completed; parent-cancel-during-drain and worker-abort each downgrade to Failed), and testing/synctest drain/worker-order assertions that fail deterministically if a finish() wait is removed. The inherited cancellation structure (inline Walk, the dispatch send, the worker cancel branches) is left unchanged for the follow-ups. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe Signed-off-by: Feng Ruohang <[email protected]>
|
Note on base / merge order. CI only triggers on PRs targeting Merge either way:
No behavioral overlap between the two commits; #138 is finalization timing, #139 is result classification. |
6c2d164 to
069a5ce
Compare
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]>
069a5ce to
46e82eb
Compare
|
Independent functional verification, 2026-09-06, against #140 head The original #139 failure now behaves correctly. I built an isolated integration of main
The targeted Go test run passed all 161 tests/subtests covering resync, replication action selection, retention removal, replica lock reconciliation, SSE-C PUT/MPU and quota behavior. The eight hosted checks attached to this PR head are green. The prior full integration suite predates #140; this new evidence is targeted tests plus the real transfer/restart matrix, not a claim that a new full suite or published image was tested. Returning the existing per-target result addresses the root cause and removes the unreliable post-transfer existence inference. Keeping the established benign-412 interpretation is necessary for an already matching replica. No blocking functional finding in this bounded change. Merge #138 before #140. When integrating #134, the resync-only target HEAD block is superseded by the outcome classifier; retain #134's sender-side SSE-C repair logic. #141 remains a separate dispatch-scoping fix, and #137/#133 remain separate cancellation/multi-pool work. #139 should close when this fix reaches main, not merely because candidate tests pass. |
Description
Fixes #139. Stacked on #138 (
fix/issue-136-resync-counter-flush) — review/merge #138 first; this PR's base retargets tomainonce #138 lands.resyncBucket's worker classified a per-object resync as success whenever the target version merely existed (tgt.StatObject), ignoring the outcome of thereplicateObject/replicateDeleteit had just run. A quota-rejected update leaves the old version in place, so it was falsely recordedCompleted/ success (persisted across restart). #134's SSE-C internal HEAD marker madeStatObjectsucceed for SSE-C objects too, exposing the same defect there; the delete path had the mirror flaw; andFailedSizewas never incremented.Fix (
cmd/bucket-replication.go)replicateObjectandreplicateDeletenow return the per-targetreplicatedInfosthey already build (early returns →replicatedInfos{}; the metadata-persistence side effects are unchanged). The non-resync callers are call statements that discard the value.resyncResultFor/resyncTargetSucceeded, using theopts.arntarget's own outcome:ReplicationStatus == Completed, tolerating only the benign duplicatePreconditionFailed(412) the destination returns for an exact ETag+version match;VersionPurgeStatus == VersionPurgeComplete(a purge leavesReplicationStatusempty);opts.arnabsent from the result, counts as a failure, andFailedSizeis now recorded.StatObject-existence block (and its delete-marker/MethodNotAllowedheuristic, now subsumed) is removed. fix: retransmit and re-order Object Lock for SSE-C replicas (single erasure set) #134's SSE-C HEAD marker inreplicateAllis untouched.Scope / follow-ups
Counter timing is #138; cancellation robustness is #137; multi-pool is #133. Two items are deliberately out of scope: the compressed/encrypted byte-size approximation (pre-existing), and cross-ARN dispatch scoping (any-target
mustResynccan route a non-opts.arnobject to a worker → conservatively counted a failure) — tracked as a follow-up.Adversarial review
Codex Astra 6 (Max), 2 rounds → VERDICT PASS. Round 1 caught two over-strict misclassifications (successful version purge; benign 412); round 2 confirmed both fixes correct and that all other result shapes (Replica/pending/empty/arbitrary
Completed+Err, quota rejection) classify correctly.How to test
Table-driven, 10 cases incl. the key regressions (failed update over an existing version → 1 failed / 196608 bytes / 0 replicated; version-purge complete/failed; benign 412). Red-on-revert confirmed for the existence heuristic and for both round-2 branches.
gofmt/go vet/go build/-raceclean; full-run 'Resync' -count=1passes (incl. #138's finalize tests on the stack).Types of changes
Checklist
git commit -s)gofmt/go vet/go build/-raceclean; Resync tests pass🤖 Generated with Claude Code
https://claude.ai/code/session_01L7qJqWwy8oFA6aCXWRzXQe