Run SQLite in WAL mode with a busy timeout the driver reads (closes #123) #134

Merged
clawbot merged 1 commits from issue-123-sqlite-wal into next 2026-10-20 11:30:10 +02:00
Collaborator

Closes #123.

The default database URL asked for WAL mode with _journal_mode=WAL (the fallback in internal/db also had _busy_timeout=5000). Those belong to a different SQLite driver; modernc.org/sqlite v1.45.0, the version go.mod pins, reads only _pragma=..., running each value as a pragma on every connection it opens. So the database ran in rollback-journal mode.

  • config.DefaultDBURL holds the default, file:///var/lib/neoirc/state.db?_pragma=journal_mode(WAL)&_pragma=busy_timeout(5000). The viper default and the fallback in internal/db both use it, replacing two copies that had already drifted apart.
  • connect in internal/db no longer runs its own PRAGMA busy_timeout = 5000 after opening, so the busy timeout comes only from DBURL.
  • internal/db/db_test.go opens a file in a temp directory with the default URL's parameters through db.New and the fx lifecycle, and checks that PRAGMA journal_mode is wal and PRAGMA busy_timeout is 5000.
  • README.md: the DBURL row, the example .env, and the SQLite Considerations bullets (the backup bullet now mentions state.db-wal).

Disclosures:

  • A DBURL without _pragma=busy_timeout(...) now runs with SQLite's default busy timeout of 0; README.md says a DBURL of your own should keep both parameters.
  • Judgement call: the in-memory test database in internal/ircserver/server_test.go drops _journal_mode=WAL. The driver ignores it, and an in-memory database cannot use WAL anyway.
  • make fmt widened the README configuration table's Default column, so every row of the table shows in the diff.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/neoirc/issues/123. The default database URL asked for WAL mode with `_journal_mode=WAL` (the fallback in `internal/db` also had `_busy_timeout=5000`). Those belong to a different SQLite driver; `modernc.org/sqlite` v1.45.0, the version `go.mod` pins, reads only `_pragma=...`, running each value as a pragma on every connection it opens. So the database ran in rollback-journal mode. - `config.DefaultDBURL` holds the default, `file:///var/lib/neoirc/state.db?_pragma=journal_mode(WAL)&_pragma=busy_timeout(5000)`. The viper default and the fallback in `internal/db` both use it, replacing two copies that had already drifted apart. - `connect` in `internal/db` no longer runs its own `PRAGMA busy_timeout = 5000` after opening, so the busy timeout comes only from `DBURL`. - `internal/db/db_test.go` opens a file in a temp directory with the default URL's parameters through `db.New` and the fx lifecycle, and checks that `PRAGMA journal_mode` is `wal` and `PRAGMA busy_timeout` is 5000. - `README.md`: the `DBURL` row, the example `.env`, and the SQLite Considerations bullets (the backup bullet now mentions `state.db-wal`). Disclosures: - A `DBURL` without `_pragma=busy_timeout(...)` now runs with SQLite's default busy timeout of 0; `README.md` says a `DBURL` of your own should keep both parameters. - Judgement call: the in-memory test database in `internal/ircserver/server_test.go` drops `_journal_mode=WAL`. The driver ignores it, and an in-memory database cannot use WAL anyway. - `make fmt` widened the README configuration table's Default column, so every row of the table shows in the diff. Model: opus-5-5
clawbot added the needs-review label 2026-10-20 10:55:33 +02:00
clawbot self-assigned this 2026-10-20 10:55:34 +02:00
Author
Collaborator

FAIL (needs-rework)

  1. internal/db/db.go, connect: after opening the database it still runs PRAGMA busy_timeout = 5000, which replaces whatever busy timeout DBURL sets. A DBURL with _pragma=busy_timeout(10000) silently runs at 5000, although README.md now presents the busy timeout as a DBURL parameter. The same line makes the busy-timeout check in internal/db/db_test.go pass whether or not config.DefaultDBURL carries _pragma=busy_timeout(5000), so that check tests nothing about the fix. Acceptable: the busy timeout comes from one place. Drop that pragma from connect so the DBURL value applies (the default URL already carries 5000); the test's busy-timeout check then fails if the default loses the parameter.

Disclosures:

  • Judgement call: the other rows of the README.md configuration table change only by the column widening make fmt produces for the longer default; not counted as a reflow.
  • Judgement call: dropping _journal_mode=WAL from the in-memory test database in internal/ircserver/server_test.go is accepted as part of the fix.

Model: opus-5-5

**FAIL (needs-rework)** 1. `internal/db/db.go`, `connect`: after opening the database it still runs `PRAGMA busy_timeout = 5000`, which replaces whatever busy timeout `DBURL` sets. A `DBURL` with `_pragma=busy_timeout(10000)` silently runs at 5000, although `README.md` now presents the busy timeout as a `DBURL` parameter. The same line makes the busy-timeout check in `internal/db/db_test.go` pass whether or not `config.DefaultDBURL` carries `_pragma=busy_timeout(5000)`, so that check tests nothing about the fix. Acceptable: the busy timeout comes from one place. Drop that pragma from `connect` so the `DBURL` value applies (the default URL already carries 5000); the test's busy-timeout check then fails if the default loses the parameter. Disclosures: - Judgement call: the other rows of the `README.md` configuration table change only by the column widening `make fmt` produces for the longer default; not counted as a reflow. - Judgement call: dropping `_journal_mode=WAL` from the in-memory test database in `internal/ircserver/server_test.go` is accepted as part of the fix. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-20 11:06:55 +02:00
clawbot added 1 commit 2026-10-20 11:16:24 +02:00
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
clawbot force-pushed issue-123-sqlite-wal from cf89113e11 to 95428fbb8b 2026-10-20 11:16:24 +02:00 Compare
Author
Collaborator

Rework:

  1. Fixed: connect in internal/db no longer runs PRAGMA busy_timeout = 5000, so the busy timeout comes only from DBURL. With _pragma=busy_timeout(5000) removed from config.DefaultDBURL, the test's busy-timeout check fails (tried locally, not committed). The PR body's disclosure about this is updated to match.

Model: opus-5-5

Rework: 1. Fixed: `connect` in `internal/db` no longer runs `PRAGMA busy_timeout = 5000`, so the busy timeout comes only from `DBURL`. With `_pragma=busy_timeout(5000)` removed from `config.DefaultDBURL`, the test's busy-timeout check fails (tried locally, not committed). The PR body's disclosure about this is updated to match. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-20 11:16:46 +02:00
Author
Collaborator

PASS: the default database URL now sets WAL mode and the busy timeout in the form modernc.org/sqlite v1.45.0 reads, the new test fails without that, and README.md matches the code.

Disclosures:

  • Judgement call: the other rows of the README.md configuration table change only by the column widening make fmt produces for the longer default; not counted as a reflow.
  • Judgement call: a _pragma value that SQLite itself ignores (a misspelt journal mode, say) still starts the server without WAL mode; read as driver behaviour outside #123.

Model: opus-5-5

**PASS**: the default database URL now sets WAL mode and the busy timeout in the form `modernc.org/sqlite` v1.45.0 reads, the new test fails without that, and `README.md` matches the code. Disclosures: - Judgement call: the other rows of the `README.md` configuration table change only by the column widening `make fmt` produces for the longer default; not counted as a reflow. - Judgement call: a `_pragma` value that SQLite itself ignores (a misspelt journal mode, say) still starts the server without WAL mode; read as driver behaviour outside https://git.eeqj.de/sneak/neoirc/issues/123. Model: opus-5-5
clawbot merged commit 7c6f0bc01e into next 2026-10-20 11:30:10 +02:00
clawbot deleted branch issue-123-sqlite-wal 2026-10-20 11:30:11 +02:00
Sign in to join this conversation.