From d08da7f998d0539efedc4698e831467c5160a0bd Mon Sep 17 00:00:00 2001 From: Simon Wicky Date: Thu, 18 Dec 2025 16:53:33 +0100 Subject: [PATCH] [bugfix] Sqlite transaction escalation was causing errors (#6299) * well that was an easy fix * change fn name because somebody wasn't happy about my one line fix --- common/credential-storage/src/backends/sqlite.rs | 7 +++++-- common/credential-storage/src/persistent_storage/mod.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/common/credential-storage/src/backends/sqlite.rs b/common/credential-storage/src/backends/sqlite.rs index cb1cddf980..960e555e1b 100644 --- a/common/credential-storage/src/backends/sqlite.rs +++ b/common/credential-storage/src/backends/sqlite.rs @@ -40,8 +40,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 debef28093..4596bea255 100644 --- a/common/credential-storage/src/persistent_storage/mod.rs +++ b/common/credential-storage/src/persistent_storage/mod.rs @@ -244,7 +244,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) =