diff --git a/core/mvcc/database/mod.rs b/core/mvcc/database/mod.rs index 17f930a2f..baca0657d 100644 --- a/core/mvcc/database/mod.rs +++ b/core/mvcc/database/mod.rs @@ -517,6 +517,9 @@ impl StateTransition for CommitStateMachine { 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 MvStore { 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();