From 1bdfabcac7c28ce07a6be98e565a11e12b8cbc7e Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 14 Sep 2025 13:51:36 +0300 Subject: [PATCH] whopper: Generate different transaction modes with MVCC --- whopper/main.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/whopper/main.rs b/whopper/main.rs index f02e6cc3a..00b968886 100644 --- a/whopper/main.rs +++ b/whopper/main.rs @@ -63,6 +63,7 @@ struct SimulatorContext { opts: Opts, stats: Stats, disable_indexes: bool, + enable_mvcc: bool, } #[derive(Default)] @@ -168,6 +169,7 @@ fn main() -> anyhow::Result<()> { opts: Opts::default(), stats: Stats::default(), disable_indexes: args.disable_indexes, + enable_mvcc: args.enable_mvcc, }; let progress_interval = config.max_steps / 10; @@ -387,12 +389,19 @@ fn perform_work( FiberState::Idle => { let action = rng.random_range(0..100); if action <= 29 { - // Start transaction - // FIXME: use deferred when it's fixed! - if let Ok(stmt) = context.fibers[fiber_idx].connection.prepare("BEGIN") { + let begin_cmd = if context.enable_mvcc { + match rng.random_range(0..3) { + 0 => "BEGIN DEFERRED", + 1 => "BEGIN IMMEDIATE", + _ => "BEGIN CONCURRENT", + } + } else { + "BEGIN" + }; + if let Ok(stmt) = context.fibers[fiber_idx].connection.prepare(begin_cmd) { context.fibers[fiber_idx].statement.replace(Some(stmt)); context.fibers[fiber_idx].state = FiberState::InTx; - trace!("{} BEGIN", fiber_idx); + trace!("{} {}", fiber_idx, begin_cmd); } } else if action == 30 { // Integrity check