Repository navigation
pool: the archive sweep marks a claim when its archive starts, not when the sweep picks it - #679
Merged
Merged
Conversation
…en the sweep picks it archiveOnce set m.archiving for every victim at the pick, but the archives run on a bounded set of workers, each one an export and an upload, so a victim late in a batch carried the mark for as long as the batch took. Every reader of the mark takes it to mean that an archive of the claim is running. A wake does not look at it, so a claim its owner woke while it waited in the queue was running and still got a 409 "sandbox is archived" on renew, was skipped by the liveness and replication passes, and was refused a move or an evacuation until its worker came up. If its lease ended in that wait and on_expire was not archive, the reap destroyed a running claim whose owner had asked to renew in time. The worker now checks under m.mu that it still holds the record and that the claim is still due, and only then marks it and archives it. A claim that woke, was archived by the reap or was replaced while it waited is skipped. The bug predates the pool cleanup and is in v0.1.38.
CMGS
added a commit
that referenced
this pull request
Dec 1, 2026
…e refuses a resize into a replicating pool (#684) Docs for behaviour that PRs merged since v0.1.38 changed: egress.md states that an origin's early answer or the proxy's own 502 or 429, sent before the guest's request body was read to its end, carries Connection: close, arrives whole, and ends that guest connection (#681); cluster.md states the resize refusal on a node whose lease is overdue and that a claim resized into its policy pool is replicated from then on (#676), and that the hourly row settling leaves a claim a transition holds to the next pass (#674); CHECKLIST.md states the archive sweep worker's check before it marks a claim (#679); deploy.md states that a preview URL can show a truncated reply when the guest app answers before it read the whole request body.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by the review round on main after #677 and #678. The bug is older than that work and is in v0.1.38.
What was wrong
archiveOncepicks every hibernated claim that is idle pastarchive_afterand setm.archivingfor each one at the pick. The archives then run on a bounded set of workers, each one a snapshot export and an upload, so a claim late in a batch carried the mark for as long as the batch took, although no archive of it had started.Every reader of the mark takes it to mean "an archive of this claim is running", and a wake does not look at it. So a claim that its owner woke while it waited in the queue was running, and until its worker came up:
POST /renewanswered 409sandbox is archived; a wake or an exec wakes it first;A wake renews the lease only when it has already lapsed. If the lease ended inside that wait and
on_expirewas notarchive, the reap destroyed a running claim whose owner had asked to renew in time.A batch gets long when many claims hibernate together, when
archive_afteris turned on for a pool that already holds hibernated claims, and when archives retry together after a store outage.The fix
The sweep marks a claim when its archive starts. The worker takes
m.mu, checks that it still holds the record and that the claim is still due (archiveDueLocked, the pick's own predicate), and only then marks it and callsarchive. A claim that woke, that the reap archived at its lease end, or that a resize replaced while it waited is skipped with no log, aserrWokeMeanwhilewas.archiveis unchanged: the reap and the evacuation still mark before they call it. A reap that takes a queued claim now archives it itself, and the queued worker finds the mark or the checkpoint and skips. Two archive sweeps cannot overlap (m.sweeps.archive).A renew considered and rejected: letting
Renewthrough whenever the marked claim has no snapshot. The reap marks a running claim at its deadline before it pauses and archives it; a renew let through there would answer 200 and then lose its lease to the archive's retention deadline.Test
TestAClaimWokenWhileItWaitsForItsArchiveRenews: two due claims, one maintenance slot, the first archive held inside the store's publish; the second claim carries no mark, wakes and renews; after the release the first is archived and the second runs. On the oldarchive.goit fails 3 of 3:On the fix it passes with
-race -count=20.TestRemovedTenantsClaimIsNeitherArchivedNorWokenNorForkedreadm.archivingright afterarchiveOnce; with the mark set later that check would pass without testing anything, so it now waits for the sweep to finish before it reads.Cost
Nothing on the claim path. Per archived claim: one more
m.musection and one more evaluation of the due predicate in the worker. The pick no longer writes the map.Gates
golangci-lint10 ×0 issues.(5 modules × darwin, linux),asland fmt clean, comments +0 −1 inarchive.go, race tests green on darwin and in a Linux container. Production +19 −12, tests +52.Not run on hardware: the change is one decision under
m.mu, and a cell would need uploads slow enough to hold a queue. The unit test holds the store instead.