Files
buzz/desktop/scripts
npub1mn7jgtj4w2pd0g0zeuhxsa6jy6p0rewxz4kujt98my82ahfmp72sxjexk7andWill Pfleger e7d4de2294 fix(archive): use immediate tx for owner_p kind merge
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>
2026-07-06 17:47:05 -04:00
..