mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-20 07:25:14 +01:00
pager: only ROLLBACK your own transaction, not if someone else is writing
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::storage::sqlite3_ondisk::{
|
||||
use crate::storage::wal::{CheckpointResult, Wal};
|
||||
use crate::types::{IOResult, WalInsertInfo};
|
||||
use crate::util::IOExt as _;
|
||||
use crate::{return_if_io, Completion};
|
||||
use crate::{return_if_io, Completion, TransactionState};
|
||||
use crate::{turso_assert, Buffer, Connection, LimboError, Result};
|
||||
use parking_lot::RwLock;
|
||||
use std::cell::{Cell, OnceCell, RefCell, UnsafeCell};
|
||||
@@ -819,7 +819,9 @@ impl Pager {
|
||||
tracing::trace!("end_tx(rollback={})", rollback);
|
||||
if rollback {
|
||||
self.rollback(schema_did_change, connection)?;
|
||||
self.wal.borrow().end_write_tx();
|
||||
if matches!(connection.transaction_state.get(), TransactionState::Write { .. }) {
|
||||
self.wal.borrow().end_write_tx();
|
||||
}
|
||||
self.wal.borrow().end_read_tx();
|
||||
return Ok(IOResult::Done(PagerCommitResult::Rollback));
|
||||
}
|
||||
|
||||
@@ -2086,6 +2086,7 @@ pub fn op_auto_commit(
|
||||
if *rollback {
|
||||
// TODO(pere): add rollback I/O logic once we implement rollback journal
|
||||
return_if_io!(pager.end_tx(true, schema_did_change, &conn, false));
|
||||
conn.transaction_state.replace(TransactionState::None);
|
||||
conn.auto_commit.replace(true);
|
||||
} else {
|
||||
conn.auto_commit.replace(*auto_commit);
|
||||
|
||||
Reference in New Issue
Block a user