From 4407bf5d7df1571b58bab4fc36bcf8634e900af7 Mon Sep 17 00:00:00 2001 From: Handora Date: Mon, 17 Jun 2024 10:24:03 +0000 Subject: [PATCH] Donot mvcc undo for multiset if callback registered --- src/storage/memtable/ob_memtable.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/storage/memtable/ob_memtable.cpp b/src/storage/memtable/ob_memtable.cpp index d7a368d49..1af53cdc0 100644 --- a/src/storage/memtable/ob_memtable.cpp +++ b/src/storage/memtable/ob_memtable.cpp @@ -1623,9 +1623,6 @@ void ObMemtable::lock_row_on_frozen_stores_on_failure( TRANS_LOG(WARN, "sstable conflict will occurred when lock operation", K(ctx), KPC(this), K(writer_dml_flag)); } - } else { - // Tip1: mvcc_write guarantee the tnode will not be inserted if error is reported - (void)mvcc_engine_.mvcc_undo(value); } if (OB_TRY_LOCK_ROW_CONFLICT == ret) { ret = post_row_write_conflict_(ctx.mvcc_acc_ctx_, @@ -2655,9 +2652,12 @@ int ObMemtable::multi_set_( TRANS_LOG(WARN, "Failed to encode memory table key", K(ret)); } else { ret = rows_info.get_error_code(); - lock_row_on_frozen_stores_on_failure(blocksstable::ObDmlFlag::DF_INSERT, mtk, - ret, mvcc_rows[conflict_idx].mvcc_row_, - context, mvcc_rows[conflict_idx].write_result_); + lock_row_on_frozen_stores_on_failure(blocksstable::ObDmlFlag::DF_INSERT, + mtk, + ret, + mvcc_rows[conflict_idx].mvcc_row_, + context, + mvcc_rows[conflict_idx].write_result_); } } @@ -2918,7 +2918,16 @@ int ObMemtable::mvcc_write_( context, value, res))) { - lock_row_on_frozen_stores_on_failure(arg.data_->dml_flag_, *key, ret, value, context, res); + lock_row_on_frozen_stores_on_failure(arg.data_->dml_flag_, + *key, + ret, + value, + context, + res); + if (res.has_insert()) { + (void)mvcc_engine_.mvcc_undo(value); + res.is_mvcc_undo_ = true; + } } else if (OB_FAIL(mvcc_engine_.ensure_kv(&stored_key, value))) { if (res.has_insert()) { (void)mvcc_engine_.mvcc_undo(value);