Skip to content

pool: an archive job leaves a claim a wake took since it was marked - #703

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

CMGS merged 1 commit into
mainfrom
pool/archive-job-leaves-taken

Conversation

@CMGS

@CMGS CMGS commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #698.

What was wrong

A reap or sweep job marks a claim and later archives it, and between the two it checked only the claim's shape. A wake in between gives a lapsed claim a fresh lease, and since #696 a renew while that woken claim's VM is up can set a new deadline and expiry action. If the claim was hibernated again before the job's first look, the job archived it anyway and overwrote the lease with the retention deadline. Three doors, one shape: the reaper's pause-then-archive of a running claim, the reaper's archive of a hibernated one, and the idle archive sweep.

The change

Under a mark, a client can change a claim's lease or expiry action only through a taker: the wake renews it, and a renew is accepted only for a claim a taker took (#696). So the taken mark is the signal, and no deadline is re-read: pauseArchive, before its hibernate, and archive(), where it reads the snapshot under the Transition lock, give up a claim whose mark is taken (errWokeMeanwhile, the same exit as a wake during the export; the next sweep decides again).

One exception: a claim the node is evacuating is archived whatever its mark, as before. An evacuation drops a claim from its run on any error. Wakes and resizes are refused for an evacuating claim at admission, so a taken mark can appear there only from a wake already past admission or from the restart of a failed claim, which skips that check.

Unchanged: the check after the export (a wake during the export is caught by the snapshot), and a resize undone during the export (same snapshot, nothing renewed; the export archives the claim).

Kept: between a taken claim's second hibernate and the job's give-up, a renew or a move of that claim is still refused as archiving (409; a wake clears it). Lifting that would let a resize undone during an export archive over a renew that was granted.

Not covered, as on main: operator changes after the mark (archive_after set to 0, a tenant removed, replication switched).

Production +9 −3, tests +88 −55.

Tests

Two tests from #696 staged exactly these doors and asserted the old outcome (the job archives; a renew during its export is refused). The outcome changes by design, so they are rewritten:

  • the reaper's pause of a running, expired claim that was hibernated and woken since the mark: the job returns without hibernating or exporting, the claim runs on with the wake's lease, the mark is gone, a renew then stands;
  • the reaper's archive of a hibernated, expired claim that was woken and hibernated again since the mark: renew is refused while it waits for the job; the job gives up, the claim is not archived, keeps its snapshot and the wake's lease;
  • new: under evacuation the same pause still archives the claim.

Both rewritten tests fail on main (the job returns nil and the deadline is the retention deadline). Mutants, each killed by a named test: the helper always false, the helper without the evacuating term, each of its two uses removed, and #696's old rule.

Hot path

Nothing on the claim path. pauseArchive: one map read in a section that already holds m.mu. archive(): one m.mu lock and one map read per archive job.

A job that gives up sets the claim's archive retry time one minute ahead, as a wake during the export already does.

Not covered on hardware

The doors need a wake and a hibernate between a sweep's mark and its job; on a host that is a race with no lever. The tests stage the order directly.

Gates

sbx-gate.sh (lint, fmt-check, asl, tests with -race, both GOOS) ends GATES PASS on this head, which sits on main.

A reap or sweep job marked a claim and later archived it after checking only
its shape. A wake in between gave a lapsed claim a fresh lease, and since #696
a renew while its VM was up could set a new deadline and expiry action; a
second hibernate before the job's first look let the job archive it anyway and
overwrite the lease with the retention deadline.

The taken mark records those client changes under a mark (a wake's lease, a
renew's deadline and on_expire), so pauseArchive and archive() now give up a
claim whose mark is taken, except one the node is evacuating, which is
archived whatever its lease as before. Operator changes after the mark
(archive_after set to 0, a tenant removed, replication switched) are not
covered, as on main.

Fixes #698
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 reaper's archive jobs do not recheck that the claim is still due

1 participant