diff --git a/common/credential-storage/src/backends/sqlite.rs b/common/credential-storage/src/backends/sqlite.rs index d196cad0490..459085e7c9b 100644 --- a/common/credential-storage/src/backends/sqlite.rs +++ b/common/credential-storage/src/backends/sqlite.rs @@ -39,8 +39,11 @@ impl SqliteEcashTicketbookManager { Ok(()) } - pub(crate) async fn begin_storage_tx(&self) -> Result, sqlx::Error> { - self.connection_pool.begin().await + /// Starts a write (IMMEDIATE) transaction, to prevent issue when upgrading from a read one to a write one + pub(crate) async fn begin_storage_write_tx( + &self, + ) -> Result, sqlx::Error> { + self.connection_pool.begin_with("BEGIN IMMEDIATE").await } pub(crate) async fn insert_pending_ticketbook( diff --git a/common/credential-storage/src/persistent_storage/mod.rs b/common/credential-storage/src/persistent_storage/mod.rs index b3302983ee5..dab13395b59 100644 --- a/common/credential-storage/src/persistent_storage/mod.rs +++ b/common/credential-storage/src/persistent_storage/mod.rs @@ -243,7 +243,7 @@ impl Storage for PersistentStorage { tickets: u32, ) -> Result, Self::StorageError> { let deadline = ecash_today().ecash_date(); - let mut tx = self.storage_manager.begin_storage_tx().await?; + let mut tx = self.storage_manager.begin_storage_write_tx().await?; // we don't want ticketbooks with expiration in the past let Some(raw) =