Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database connection init #2440

Merged
merged 3 commits into from
May 11, 2022
Merged

Database connection init #2440

merged 3 commits into from
May 11, 2022

Conversation

jjlin
Copy link
Contributor

@jjlin jjlin commented Apr 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:

This is probably mainly useful for running connection-scoped pragma statements.
`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.

`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".
src/config.rs Outdated Show resolved Hide resolved
The main pro is less config options, while the main con is less clarity in
what the defaults are for the various database types.
@dani-garcia dani-garcia merged commit 451ad47 into dani-garcia:main May 11, 2022
@dani-garcia
Copy link
Owner

With this merged we can probably consider removing some of the uses of crate::util::retry() which I think was added to solve this "Database locked" issue as well.

@BlackDex
Copy link
Collaborator

That depends. If this was only for sqlite, the probably yes.
It could also happen with mysql when deleting and adding ciphers are done at the same time and a lock is on a table of course.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants