#245. The retention purge listed the archived sites past the 30-day
window once, then deleted each on the farm and its row without reading
the site again, so a restore accepted in between could finish and then
lose the site. The purge now takes each candidate in its own READ
COMMITTED transaction: it locks the site's lifecycle instance (the lock
every request's intake takes), then the site row by id while the row is
still archived and past the window, checks that no request on the site
is open, and holds both locks through the farm delete and the row
delete. A site that changed, went missing or has an open request is
left to a later tick; placements are released after the commit, and no
usage is written, since only archived sites without an open request
are deleted. A farm refusal keeps the row; a 404 from the farm counts
as deleted. docs/database-locks.md states the order.
Accepted: a farm delete under the locks can run 30 seconds against the
server's eight-second write timeout, so a member request on that site
waits and can lose its answer (#290). Not in this change: a request
made from a page loaded before the purge is accepted and then declined
when its workflow reads the site (recorded on #284).
Tests: TestRetentionPurgeRechecksCandidates_DB,
TestRetentionPurgeWaitsForLifecycleIntake_DB,
TestRetentionPurgeWaitsForSiteEligibility_DB,
TestRetentionPurgeHoldsLocksThroughFarmDelete_DB,
TestRetentionPurgeLeavesARestoreInFlight_DB and
TestRetentionPurgeFailures_DB. Checked by reading only: a failed
eligibility or open-request read inside the purge's transaction returns
before the farm call; nothing in the test kit fails that read, and no
production seam was added for it. Connection loss with an unknown
commit, a remote delete after cancellation and process death remain
analysis-only.
Full suite on reset databases: 5174 passed, 16 skipped, none failed.
No page changed.
Breaks, all CAUGHT (16):
- current status
- current archive time
- null archive time
- strict cutoff
- candidate identity
- open request skips
- lifecycle instance lock
- request snapshot after waiting
- row update is a successful skip
- site row lock
- locks last through HTTP
- local deletion
- placement release
- continue after candidate failure
- farm refusal keeps the row
- 404 is success