mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Replace DEFERRED unchecked_transaction() with BEGIN IMMEDIATE via execute_batch so the write lock is acquired before the SELECT. With DEFERRED, two concurrent first-run seed hooks (observer + metric) both read the empty owner_p snapshot, then race to write; the loser receives SQLITE_BUSY_SNAPSHOT which busy_timeout does not retry, leaving one kind silently absent until app restart. With IMMEDIATE, the second caller blocks at BEGIN until the first commits, then reads the committed row and merges its kind in. Both callers succeed and the final row contains [24200, 44200]. Also fixes the inaccurate doc-comment that claimed DEFERRED gave an exclusive write lock for the read-modify-write (it did not), and replaces the mislabeled sequential-single-connection test with a real two-connection WAL regression test using std::thread + Barrier that exercises the actual concurrent write path. Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>