From aa7a853cd20a3e10dc2acdcfae2c1e69e949c9d7 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Mon, 15 Sep 2025 11:09:19 +0300 Subject: [PATCH] mvcc: fix hang when CONCURRENT tx tries to commit and non-CONCURRENT tx is active --- core/mvcc/database/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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();