From 9632ab0a414126f90e04c2dce6c266fadf85575f Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Thu, 3 Jul 2025 16:35:37 -0300 Subject: [PATCH] rollback transaction when we fail in step --- core/storage/sqlite3_ondisk.rs | 2 +- core/vdbe/mod.rs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/storage/sqlite3_ondisk.rs b/core/storage/sqlite3_ondisk.rs index 3a9c98668..8cf56b574 100644 --- a/core/storage/sqlite3_ondisk.rs +++ b/core/storage/sqlite3_ondisk.rs @@ -1569,8 +1569,8 @@ pub fn begin_write_wal_frame( if res.is_err() { // If we do not reduce the counter here on error, we incur an infinite loop when cacheflushing *write_counter.borrow_mut() -= 1; - res?; } + res?; tracing::trace!("Frame written and synced"); Ok(checksums) } diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 17d994b68..afb18a1eb 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -382,8 +382,12 @@ impl Program { let _ = state.result_row.take(); let (insn, insn_function) = &self.insns[state.pc as usize]; trace_insn(self, state.pc as InsnReference, insn); - let res = insn_function(self, state, insn, &pager, mv_store.as_ref())?; - match res { + let res = insn_function(self, state, insn, &pager, mv_store.as_ref()); + if res.is_err() { + // TODO: see change_schema correct value + pager.rollback(false, &self.connection)? + } + match res? { InsnFunctionStepResult::Step => {} InsnFunctionStepResult::Done => return Ok(StepResult::Done), InsnFunctionStepResult::IO => return Ok(StepResult::IO),