Skip to content

Commit 9cac8c2

Browse files
AbirAbbasclaude
andcommitted
cellsync: a displacement check waits for a branch already being kept
Displaced returned at once when the hold was already stale, but a background heartbeat or follower sets stale before it finishes saving and branching the kept work. CheckLease could then return before the branch map was written. Displaced now joins lost under flushMu, whose own checks still prevent a second resolution, so the caller only returns once the kept branch exists. The window grew once displacement settles held calls before branching. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 3d3e90e commit 9cac8c2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎internal/cellsync/batch.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,10 @@ func (b *Batcher) beat(ctx context.Context) {
536536
// work is refused immediately and any pending turns are resolved under flushMu
537537
// so an in-flight publish and a watch wakeup never announce displacement twice.
538538
func (b *Batcher) Displaced(ctx context.Context) {
539-
seen, _, stale := b.view()
540-
if stale {
541-
return
542-
}
539+
// A stale hold may still be saving its kept branch under flushMu.
540+
// Joining lost waits for that resolution; the stale flag only retires
541+
// ownership and cannot acknowledge that preservation has finished.
542+
seen, _, _ := b.view()
543543
b.lost(ctx, seen)
544544
}
545545

0 commit comments

Comments
 (0)