diff --git a/core/lib.rs b/core/lib.rs index fff2001f7..4ea0234b7 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -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 ); diff --git a/core/storage/pager.rs b/core/storage/pager.rs index 4217c1ddc..21ce0f822 100644 --- a/core/storage/pager.rs +++ b/core/storage/pager.rs @@ -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(), }); diff --git a/core/storage/wal.rs b/core/storage/wal.rs index 05945d008..a4666cae7 100644 --- a/core/storage/wal.rs +++ b/core/storage/wal.rs @@ -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; } } diff --git a/core/vdbe/mod.rs b/core/vdbe/mod.rs index 48e1eb43f..c64f26688 100644 --- a/core/vdbe/mod.rs +++ b/core/vdbe/mod.rs @@ -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); } } }