mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 21:52:30 -04:00
feat: add the busy timeout pragma to the event cache store acquire() method too
It will tell us if this is sufficient to avoid locking the event cache store database, now that we have some proof that this is happening in the wild.
This commit is contained in:
@@ -178,6 +178,15 @@ impl SqliteEventCacheStore {
|
||||
async fn acquire(&self) -> Result<SqliteAsyncConn> {
|
||||
let connection = self.pool.get().await?;
|
||||
|
||||
// Specify a busy timeout so that operations are automatically retried, in case
|
||||
// the database was marked as locked, which can happen under very
|
||||
// peculiar circumstances in WAL mode.
|
||||
//
|
||||
// The timeout value is in milliseconds.
|
||||
//
|
||||
// See also https://www.sqlite.org/wal.html#sometimes_queries_return_sqlite_busy_in_wal_mode.
|
||||
connection.execute_batch("PRAGMA busy_timeout = 2000;").await?;
|
||||
|
||||
// Per https://www.sqlite.org/foreignkeys.html#fk_enable, foreign key
|
||||
// support must be enabled on a per-connection basis. Execute it every
|
||||
// time we try to get a connection, since we can't guarantee a previous
|
||||
|
||||
Reference in New Issue
Block a user