Repository navigation
Description
Tracks the inherited resync-cancellation defects deliberately left out of #136, which was scoped to counter integrity (persisted terminal counts must be complete and must not report Completed when work was dropped). These are all pre-existing on the fork baseline (e7d0e62f1) and are orthogonal to #136's counter fix; a full-lifecycle adversarial review of resyncBucket surfaced them. Analogous to how #133 tracks the multi-pool concern deferred from #120.
Decision record (maintainer ruling: narrow #136 + this follow-up; joint analysis by the maintainer and the Codex reviewer): the counter-integrity fix ships in #136; the cancellation architecture is fixed here.
Defects (all inherited from baseline)
-
Dispatch deadlock on cancellation.
cmd/bucket-replication.go— the object dispatchworkers[h%uint64(resyncParallelRoutines)] <- roiis a blocking send inside adefaultcase, outside cancellation. A full worker queue (100) plus cancellation (that worker exits, nobody drains its queue) wedges the dispatcher forever; the resync slot and result consumer never release. -
Abandoned walker goroutine on early return.
objectAPI.Walk(ctx, ...)is passed the parent context and never cancelled whenresyncBucketreturns early. The walker blocks feedingobjInfoCh(seecmd/erasure-server-pool.goWalk send) and, because normal resync runs underGlobalContext, can survive until server shutdown. -
One unkeyed cancel token cannot stop N concurrent bucket resyncs.
cmd/site-replication.gocancelSiteResyncsets every matching bucket's status toResyncCanceledbut sends a single unkeyed token to the sharedresyncCancelCh(bufferresyncWorkerCnt). The pool permits up to 10 concurrent bucket resyncs; only one bucket's dispatcher/worker consumes the token, an unrelated concurrent run can consume it, and a buffered leftover token can affect a later run. A continuing bucket's finalizer can also overwrite its API-assignedCanceledwithCompleted, breaking site/bucket status agreement. -
Worker token-stealing / cancellation not observed during blocking phases. Both worker
selects readresyncCancelCh, competing for the single token with the dispatcher; and the dispatcher cannot observe cancellation while blocked on a bareobjInfoChreceive or (with the counter finish() drain) while joining workers.
Suggested direction
Give this bucket's resync an owned context.WithCancel derived from the parent that the walker, dispatcher, and workers all observe (a cancel becomes a broadcast); make the dispatch send a cancellable select case; route cancellation by resyncID so cancelSiteResync reaches every matching bucket's context; and reconcile site vs bucket terminal status so a cancelled run cannot later persist Completed. A worktree prototype of much of this exists from the #136 round-3 exploration (dispatchResync, startResyncWalk, owned resyncCtx, token rewiring) and can seed the implementation — but it needs the per-resyncID pool-level routing (item 3) which #136's single-bucket work did not cover, and its own adversarial review.
Acceptance criteria
- Cancellation during a bare walk receive and during worker finalization is observed (no readerless interval).
- A full worker queue plus cancellation cannot deadlock the dispatcher; the resync slot and consumer always release.
-
Walkruns under an owned context cancelled on everyresyncBucketexit; no walker goroutine leak. -
cancelSiteResyncreliably stops every matching bucket resync (routing keyed by resync ID), with no cross-run token consumption and no stale buffered token affecting a later run. - Site-level and per-bucket terminal status stay consistent under cancellation (a cancelled run never later persists
Completed). - Deterministic (
testing/synctest) regressions for each of the above.
Non-goals
- The counter-integrity fix (drain-before-persist, parent-cancel-before-persist, worker-abort classification) — that is [P2] Resync publishes Completed before the final object counters are persisted #136.
- Multi-pool replica-write concerns — that is [P2] Multi-pool: replica-write Object Lock reconciliation is not authoritative across server pools #133.
Activity
Vonng commentedon Sep 15, 2026
This was resolved in PR #162, merged as
d1105bbb.Each resync run now owns a cancelable context. Cancellation targets the resync ID and reaches both active and queued runs, including a walker or dispatcher blocked on work. Registration and finalization protect against canceled or stale runs overwriting newer state, and resumed runs retain their leader context until they finish. Successful runs still drain their final results before persisting terminal counters, preserving the accounting fix from #136.
The merged change includes race-tested regressions for cancellation, blocked dispatch, terminal-state races and recovery. The resync lifecycle documentation explains the implementation and its concurrency boundaries.
Availability: this fix is on
main, but is not included in ServerRELEASE.2026-09-03T13-18-01Z, still the latest published Server as of September 16. See the component and release matrix; final release acceptance is tracked in #203.