storage: refuse regressed frontiers before streaming payloads

This commit is contained in:
pingqiu committed 2026-11-19 20:16:34 -08:00
1 parent 9da685d89e
commit 48b4c0cc18
2 files changed
+16 -11

No files matched your search

+11 -8
View File
@@ -889,6 +889,17 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
// Do not sample the owned map after COW writers are admitted again.
births := l.captureBirths(candidates, h)
if h < baseHead.RemoteLSN && !l.supersededBy(baseHead) {
l.s.captureMu.Unlock()
st.BarrierPauseNs = time.Since(pauseStart).Nanoseconds()
// HEAD holds the image of a later LSN than this host's log has
// reached: publishing would move remote_lsn backwards. Refused
// before any upload. (A HEAD of a newer holder fences below.)
l.abortCut(all)
l.dropIntents(ctx, intents)
return chunkCutResult{}, fmt.Errorf("%w: %w: cut LSN %d, HEAD remote_lsn %d", errChunkCaptureRefused, errChunkLSNBehind, h, baseHead.RemoteLSN)
}
st.CandidateChunks = len(candidates)
var copyErr error
copyStart := time.Now()
@@ -943,14 +954,6 @@ func (l *chunkLayerImpl) captureLocked(ctx context.Context, detach bool) (res ch
if b := l.cfg.BarrierBound; b > 0 && st.BarrierCopyChunks > b {
st.BarrierOverBound = true
}
if h < baseHead.RemoteLSN && !l.supersededBy(baseHead) {
// HEAD holds the image of a later LSN than this host's log has
// reached: publishing would move remote_lsn backwards. Refused
// before any upload. (A HEAD of a newer holder fences below.)
l.abortCut(all)
l.dropIntents(ctx, intents)
return chunkCutResult{}, fmt.Errorf("%w: %w: cut LSN %d, HEAD remote_lsn %d", errChunkCaptureRefused, errChunkLSNBehind, h, baseHead.RemoteLSN)
}
// Upload only what changed against HEAD.
next := copyHead(baseHead)
+5 -3
View File
@@ -191,12 +191,14 @@ stateDiagram-v2
Stage --> Quiesce: at most 3 pre-copy rounds
Quiesce --> OpenWindow: Sync H and D fixed under barrier
OpenWindow --> Copy: release barrier
Copy --> Closed: all candidates done
Copy --> Upload: local entry released, intent durable first
Upload --> Copy: next unsent candidate
Upload --> Closed: all workers settled
Copy --> Aborted: error, cancellation, observed fence, recovery or close
Upload --> Aborted: error, cancellation, observed fence, recovery or close
Aborted --> Refused: drain owners, cleanup, merge candidates
Copy --> Refused: H below HEAD RemoteLSN
Closed --> Upload: drain and cleanup; intent durable first
Upload --> Manifest
Closed --> Manifest: drain owners and cleanup
Manifest --> Readmit
Readmit --> Fenced: superseding HEAD
Readmit --> CAS