mirror of
https://github.com/block/buzz.git
synced 2026-11-04 16:31:38 +00:00
bool::then_some evaluates its argument eagerly, so every caller that lost the compare_exchange still constructed a PruneGuard and dropped it with the returned None. That Drop cleared prune_running under the winning pass, so a burst of triggers admitted multiple concurrent prunes (Gurney's live lane: 8 triggers -> 4 admitted, 3 escaped with SQLITE_BUSY). Construct the guard lazily with then(|| ..) so only the winning caller ever builds one. Add two regressions in archive_db_tests.rs: a synchronous exactly-once test where a second losing call proves the flag stays set under a held guard, and an async burst test mirroring the maybe_prune control flow proving exactly one pass enters. Reverting to then_some fails both. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>