mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-11 04:04:20 +01:00
Merge 'mvcc: fix hang when CONCURRENT tx tries to commit and non-CONCURRENT tx is active' from Jussi Saurio
Based on #3125 Closes #3120 Closes #3126
This commit is contained in:
@@ -517,6 +517,9 @@ impl<Clock: LogicalClock> StateTransition for CommitStateMachine<Clock> {
|
||||
requires_seek: true,
|
||||
};
|
||||
return Ok(TransitionResult::Continue);
|
||||
} else if mvcc_store.has_exclusive_tx() {
|
||||
// There is an exclusive transaction holding the write lock. We must abort.
|
||||
return Err(LimboError::WriteWriteConflict);
|
||||
}
|
||||
// Currently txns are queued without any heuristics whasoever. This is important because
|
||||
// we need to ensure writes to disk happen sequentially.
|
||||
@@ -1460,6 +1463,11 @@ impl<Clock: LogicalClock> MvStore<Clock> {
|
||||
self.exclusive_tx.read().as_ref() == Some(tx_id)
|
||||
}
|
||||
|
||||
/// Returns true if there is an exclusive transaction ongoing.
|
||||
fn has_exclusive_tx(&self) -> bool {
|
||||
self.exclusive_tx.read().is_some()
|
||||
}
|
||||
|
||||
/// Acquires the exclusive transaction lock to the given transaction ID.
|
||||
fn acquire_exclusive_tx(&self, tx_id: &TxID) -> Result<()> {
|
||||
let mut exclusive_tx = self.exclusive_tx.write();
|
||||
|
||||
Reference in New Issue
Block a user