diff --git a/core/mvcc/cursor.rs b/core/mvcc/cursor.rs index 0c6292010..6ffade31a 100644 --- a/core/mvcc/cursor.rs +++ b/core/mvcc/cursor.rs @@ -46,9 +46,15 @@ impl MvccLazyCursor { /// Sets the cursor to the inserted row. pub fn insert(&mut self, row: Row) -> Result<()> { self.current_pos = CursorPosition::Loaded(row.id); - self.db.insert(self.tx_id, row).inspect_err(|_| { - self.current_pos = CursorPosition::BeforeFirst; - })?; + if self.db.read(self.tx_id, row.id)?.is_some() { + self.db.update(self.tx_id, row).inspect_err(|_| { + self.current_pos = CursorPosition::BeforeFirst; + })?; + } else { + self.db.insert(self.tx_id, row).inspect_err(|_| { + self.current_pos = CursorPosition::BeforeFirst; + })?; + } Ok(()) } diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 02d64507d..f27168818 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -4625,7 +4625,7 @@ impl BTreeCursor { } }; let row = crate::mvcc::database::Row::new(row_id, record_buf, num_columns); - mv_cursor.borrow_mut().insert(row).unwrap(); + mv_cursor.borrow_mut().insert(row)?; } None => todo!("Support mvcc inserts with index btrees"), }, diff --git a/tests/integration/fuzz_transaction/mod.rs b/tests/integration/fuzz_transaction/mod.rs index 81bf4fb81..24b9aaeac 100644 --- a/tests/integration/fuzz_transaction/mod.rs +++ b/tests/integration/fuzz_transaction/mod.rs @@ -505,10 +505,10 @@ async fn test_multiple_connections_fuzz_mvcc() { weight_ddl: 0, weight_dml: 76, dml_gen_options: DmlGenOptions { - weight_insert: 34, - weight_delete: 33, - weight_select: 33, - weight_update: 0, + weight_insert: 25, + weight_delete: 25, + weight_select: 25, + weight_update: 25, }, }, ..FuzzOptions::default()