Database connection init #2151

Closed
opened 2026-04-06 03:08:32 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jjlin on 4/27/2022

Adds support for database connection init statements. This is probably mainly useful for running connection-scoped pragma statements.

Also adds default connection-scoped pragmas for SQLite:

  • PRAGMA busy_timeout = 5000 tells SQLite to keep trying for up to 5000 ms when there is lock contention, rather than aborting immediately. This should hopefully prevent the vast majority of "database is locked" panics observed since the async transition, e.g.: #2436

  • PRAGMA synchronous = NORMAL trades better performance for a small potential loss in durability (the default is FULL). The SQLite docs recommend NORMAL as "a good choice for most applications running in WAL mode".

*Originally created by @jjlin on 4/27/2022* Adds support for database connection init statements. This is probably mainly useful for running connection-scoped pragma statements. Also adds default connection-scoped pragmas for SQLite: * [`PRAGMA busy_timeout = 5000`](https://www.sqlite.org/pragma.html#pragma_busy_timeout) tells SQLite to keep trying for up to 5000 ms when there is lock contention, rather than aborting immediately. This should hopefully prevent the vast majority of "database is locked" panics observed since the async transition, e.g.: #2436 * [`PRAGMA synchronous = NORMAL`](https://www.sqlite.org/pragma.html#pragma_synchronous) trades better performance for a small potential loss in durability (the default is `FULL`). The SQLite docs recommend `NORMAL` as "a good choice for most applications running in WAL mode".
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/vaultwarden#2151