Open each event database once when callers race #327

Merged
clawbot merged 1 commits from issue-291-getdb-single-open into next 2026-09-29 04:37:31 +02:00
1 Commits
Author SHA1 Message Date
sneak c8f81d3c46 Open each event database once when callers race (closes #291)
check / check (push) Successful in 3m44s
GetDB opened the database on a cache miss and then tried to cache it,
so callers racing on a webhook's first use could each open the file,
and the losers closed their copies. On a new file the parallel opens
also create its tables at the same time, and one caller can fail with
"table already exists".

A mutex now covers the open: GetDB looks in the cache again under it,
then opens and caches. DeleteDB and CloseAll take the same mutex, so
neither runs while an open is under way. Reading an already cached
database takes no lock.

The new test starts many callers on one webhook at once and checks
that exactly one open happened.

Model: opus-5-5
2026-09-29 01:23:16 +00:00