Skip to content

pool: the expired-row job leaves a claim a wake took since it was marked - #706

Merged
CMGS merged 1 commit into
mainfrom
pool/unrow-leaves-taken
Dec 3, 2026
Merged

CMGS merged 1 commit into
mainfrom
pool/unrow-leaves-taken

Conversation

@CMGS

@CMGS CMGS commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Fixes #705.

Defect

The reaper marks an expired claim whose row is to be dropped (an archived claim's row, or the replica of a hibernated claim that does not archive at its deadline) and queues unrowExpired. The job checked only that it still held the claim. A wake between the mark and the job takes the claim (#696), and a client renew is then accepted; the job still dropped the replica and its registry row, so the claim ran with a renewed lease and no replica until the next replication round. For an archived claim the wake consumes the row itself and the job already did nothing.

Fix

unrowExpired reads archiveTakenLocked in the section that already reads held under the Transition lock and m.mu, and gives a taken claim up, as the reap pause and the archive do since #703. The deferred untrack still clears the mark. A claim under evacuation keeps today's behaviour (archiveTakenLocked is false for it), and the evacuation's pause archives it.

If nobody renews the woken claim, its deadline stays in the past (a wake renews only a claim that archives at its deadline): the next reap marks and unrows it again, and the reap after that destroys it, as any expired claim.

Tests

  • TestAnExpiredRowJobLeavesAClaimAWakeTookSinceItWasMarked: a replicated claim, hibernated, its pool's archive_after dropped through SetPools, expired; the test checks it takes the replica arm, marks it as the reaper does, wakes and renews it, runs the job, and asserts the replica, its checkpoint and its unconsumed row are kept, the mark is gone, and the claim runs with the renewed lease. On main it fails: the row is consumed and the replica dropped.
  • TestReplicaExpiryDropsTheRowThenTheClaim already pins that a marked claim nobody took is unrowed.
  • Mutants: the check removed is killed by the new test; giving up always is killed by TestReplicaExpiryDropsTheRowThenTheClaim; replacing archiveTakenLocked with a plain read of the mark survives, since the two differ only for a claim under evacuation, whose end state is the same either way (the evacuation's archive replaces the replica row).

Cost

One map read in a section that already holds m.mu, in the expired-row job only. Nothing on the claim path.

Prod +2 −2, tests +43. sbx-gate.sh ends GATES PASS with 10 × 0 issues.; go test -race -count=3 -run 'Archive|Unrow|Expired|Reap' ./pool/ passes.

A wake between the reaper's mark and the expired-row job takes the claim,
and a renew then succeeds, yet the job dropped the replica and its row:
the claim ran renewed with no replica until the next replication round.
The job now gives a taken claim up under the Transition lock, as the
reap pause and the archive do; the next reap sees it again if nobody renews.

Fixes #705
@CMGS
CMGS merged commit 6648d80 into main Dec 3, 2026
1 check passed
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.

pool: the expired-row job drops the replica of a claim a wake took since it was marked

1 participant