[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
This commit is contained in:
Simon Wicky
2025-12-18 16:53:33 +01:00
committed by GitHub
parent ae54e86bf4
commit d08da7f998
2 changed files with 6 additions and 3 deletions
@@ -40,8 +40,11 @@ impl SqliteEcashTicketbookManager {
Ok(())
}
pub(crate) async fn begin_storage_tx(&self) -> Result<Transaction<'_, Sqlite>, 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<Transaction<'_, Sqlite>, sqlx::Error> {
self.connection_pool.begin_with("BEGIN IMMEDIATE").await
}
pub(crate) async fn insert_pending_ticketbook(
@@ -244,7 +244,7 @@ impl Storage for PersistentStorage {
tickets: u32,
) -> Result<Option<RetrievedTicketbook>, 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) =