mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-09 02:04:22 +01:00
set connection state to None in vdbe rollback
This commit is contained in:
11
core/lib.rs
11
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
|
||||
);
|
||||
|
||||
@@ -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(),
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user