agent-orchestrator/backend/internal/storage/sqlite
prateek ba47212802 perf(storage): allow concurrent reads; serialize writes via a mutex
SetMaxOpenConns(1) forced every read (List/Get/GetPR/...) to queue behind
the single connection, so the dashboard's reads contended with the LCM's
writes. WAL already supports many concurrent readers, so raise the pool to 8
and instead serialize *writes* with a Store.writeMu. That keeps WAL's
single-writer rule and the revision-CAS read-then-write atomic regardless of
pool size, while reads now run in parallel across the pool.

Every write method takes writeMu (Upsert, PatchMetadata, UpsertPR/DeletePR,
the pr_check/pr_comment Replace* via inTx, the CDC outbox/offset writes,
project writes, reaction-tracker writes); reads take nothing. Added
TestConcurrentReadsAndWrites (16 writers + 16 readers) which passes under
-race.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 00:51:18 +05:30
..
gen refactor(storage): make session metadata + PR facts typed and structured 2026-05-31 00:33:13 +05:30
migrations refactor(storage): make session metadata + PR facts typed and structured 2026-05-31 00:33:13 +05:30
queries refactor(storage): make session metadata + PR facts typed and structured 2026-05-31 00:33:13 +05:30
cdc_store.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
db.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
mapping.go feat(backend): SQLite storage layer + CDC pipeline, LCM/reaper wiring 2026-05-30 16:02:07 +05:30
pr_projects_test.go refactor(storage): make session metadata + PR facts typed and structured 2026-05-31 00:33:13 +05:30
pr_store.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
project_store.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
reaction_store.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
spike_test.go feat(backend): SQLite storage layer + CDC pipeline, LCM/reaper wiring 2026-05-30 16:02:07 +05:30
store.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
store_test.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30
upsert.go perf(storage): allow concurrent reads; serialize writes via a mutex 2026-05-31 00:51:18 +05:30