Wait on a busy SQLite database and turn on WAL mode (closes #198)
check / check (push) Failing after 2s

Requests and the eviction pass write on separate connections, and with
no busy timeout a write that met another one failed at once with
"database is locked" and was lost. internal/database now adds
_pragma=busy_timeout(5000) to every db_url, the default or one the
operator sets, so such a write waits up to five seconds. The default
db_url's _journal_mode=WAL is not a parameter the driver reads, so it
is now _pragma=journal_mode(WAL). README.md and config.example.yml say
what pixa adds to db_url.

Model: opus-5-5
This commit is contained in:
2026-10-04 18:32:44 +00:00
parent 11d0393704
commit 56f42c4cce
5 changed files with 31 additions and 5 deletions
+4 -1
View File
@@ -320,7 +320,10 @@ func newFromSmartConfig(sc *smartconfig.Config) (*Config, error) {
settingName(keyDBURL), errValueEmpty)
}
c.DBURL = fmt.Sprintf("file:%s/state.sqlite3?_journal_mode=WAL", c.StateDir)
// The driver sets the journal mode only through a _pragma
// parameter. WAL lets reads go on while a write is in progress.
c.DBURL = fmt.Sprintf(
"file:%s/state.sqlite3?_pragma=journal_mode(WAL)", c.StateDir)
}
if loader.err != nil {