set connection state to None in vdbe rollback

This commit is contained in:
Pere Diaz Bou
2025-07-17 15:57:49 +02:00
parent c397588ad6
commit 14de7c55af
4 changed files with 23 additions and 7 deletions

View File

@@ -1216,8 +1216,13 @@ impl Statement {
if res.is_err() {
let state = self.program.connection.transaction_state.get();
if let TransactionState::Write { schema_did_change } = state {
self.pager
.rollback(schema_did_change, &self.program.connection)?;
if let Err(e) = self
.pager
.rollback(schema_did_change, &self.program.connection)
{
// Let's panic for now as we don't want to leave state in a bad state.
panic!("rollback failed: {:?}", e);
}
let end_tx_res =
self.pager
.end_tx(true, schema_did_change, &self.program.connection, true)?;
@@ -1226,7 +1231,7 @@ impl Statement {
.transaction_state
.set(TransactionState::None);
assert!(
matches!(end_tx_res, PagerCacheflushStatus::Done(_)),
matches!(end_tx_res, IOResult::Done(_)),
"end_tx should not return IO as it should just end txn without flushing anything. Got {:?}",
end_tx_res
);

View File

@@ -1549,7 +1549,12 @@ impl Pager {
self.checkpoint_inflight.replace(0);
self.syncing.replace(false);
self.flush_info.replace(FlushInfo {
state: FlushState::Start,
state: CacheFlushState::Start,
in_flight_writes: Rc::new(RefCell::new(0)),
dirty_pages: Vec::new(),
});
self.commit_info.replace(CommitInfo {
state: CommitState::Start,
in_flight_writes: Rc::new(RefCell::new(0)),
dirty_pages: Vec::new(),
});

View File

@@ -1130,10 +1130,13 @@ impl WalFile {
}
}
fn reset_internal_states(&self) {
fn reset_internal_states(&mut self) {
self.ongoing_checkpoint.state = CheckpointState::Start;
self.ongoing_checkpoint.min_frame = 0;
self.ongoing_checkpoint.max_frame = 0;
self.ongoing_checkpoint.current_page = 0;
self.sync_state.set(SyncState::NotSyncing);
self.syncing.set(false);
self.ongoing_checkpoint.state = CheckpointState::Start;
}
}

View File

@@ -418,7 +418,10 @@ impl Program {
_ => {
let state = self.connection.transaction_state.get();
if let TransactionState::Write { schema_did_change } = state {
pager.rollback(schema_did_change, &self.connection)?
pager.rollback(schema_did_change, &self.connection)?;
self.connection
.transaction_state
.replace(TransactionState::None);
}
}
}