mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 04:32:42 +00:00
A restore clears every row of the account, tombstones included, inside one long transaction under the account's exclusive restore lock. The nightly purge deleted expired tombstones across accounts, one statement per batch, without that lock: on an account under restore it waited on the restore's row locks for as long as the restore ran, past its statement timeout, or deadlocked with it once each side held rows the other needed. Each batch is now deleted one account at a time, in a transaction that first takes the restore lock in shared mode, the same order the consolidation passes keep. An account under restore is refused at once, kept out of the rest of the run, and purged the next night. Still one delete per account per batch, never one per row. The job reports how many accounts it deferred. The integration test holds a stand-in restore on one account while the purge runs: the purge returns without waiting, leaves that account alone and purges the other. With the lock call removed it waits out the hold. Refs #1031