Run SQLite in WAL mode with a busy timeout the driver reads (closes #123)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The default database URL asked for WAL mode with `_journal_mode` and `_busy_timeout`, which the SQLite driver does not read, so the database ran in rollback-journal mode. The default now uses the driver's `_pragma=journal_mode(WAL)` and `_pragma=busy_timeout(5000)` parameters, in one constant that both the config default and the database fallback use. The database no longer sets its own busy timeout after opening, so the URL's value applies. A new test opens a file database with those parameters through db.New and checks the journal mode and busy timeout. README.md's database text now matches, and an in-memory test database drops the same ignored parameter. Model: opus-5-5 Co-authored-by: clawbot <sneak+clawbot@sneak.cloud>
This commit was merged in pull request #134.
This commit is contained in:
@@ -21,6 +21,12 @@ const defaultMOTD = ` _ __ ___ ___ (_)_ __ ___
|
||||
Welcome to NeoIRC — IRC semantics over HTTP.
|
||||
Type /help for available commands.`
|
||||
|
||||
// DefaultDBURL is the database URL used when DBURL is not set. Its
|
||||
// _pragma parameters, which the SQLite driver runs on every connection
|
||||
// it opens, set WAL mode and a 5000 ms busy timeout.
|
||||
const DefaultDBURL = "file:///var/lib/neoirc/state.db" +
|
||||
"?_pragma=journal_mode(WAL)&_pragma=busy_timeout(5000)"
|
||||
|
||||
// Params defines the dependencies for creating a Config.
|
||||
type Params struct {
|
||||
fx.In
|
||||
@@ -71,7 +77,7 @@ func New(
|
||||
viper.SetDefault("DEBUG", "false")
|
||||
viper.SetDefault("MAINTENANCE_MODE", "false")
|
||||
viper.SetDefault("PORT", "8080")
|
||||
viper.SetDefault("DBURL", "file:///var/lib/neoirc/state.db?_journal_mode=WAL")
|
||||
viper.SetDefault("DBURL", DefaultDBURL)
|
||||
viper.SetDefault("SENTRY_DSN", "")
|
||||
viper.SetDefault("METRICS_USERNAME", "")
|
||||
viper.SetDefault("METRICS_PASSWORD", "")
|
||||
|
||||
Reference in New Issue
Block a user