From c01b00e61e0b913733bc2bc2b0945a9003a82aa1 Mon Sep 17 00:00:00 2001 From: mwish Date: Tue, 5 Nov 2024 10:18:36 +0800 Subject: [PATCH] fix(bugfix): for txn_write_batch creation (#2648) Co-authored-by: Twice --- src/storage/storage.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/storage/storage.cc b/src/storage/storage.cc index 2eead08ace6..234309f5f1a 100644 --- a/src/storage/storage.cc +++ b/src/storage/storage.cc @@ -868,9 +868,11 @@ Status Storage::BeginTxn() { // The EXEC command is exclusive and shouldn't have multi transaction at the same time, // so it's fine to reset the global write batch without any lock. is_txn_mode_ = true; - txn_write_batch_ = - std::make_unique(rocksdb::BytewiseComparator() /*default backup_index_comparator */, - 0 /* default reserved_bytes*/, GetWriteBatchMaxBytes()); + // Set overwrite_key to false to avoid overwriting the existing key in case + // like downstream would parse the replication log etc. + txn_write_batch_ = std::make_unique( + /*backup_index_comparator=*/rocksdb::BytewiseComparator(), + /*reserved_bytes=*/0, /*overwrite_key=*/false, /*max_bytes=*/GetWriteBatchMaxBytes()); return Status::OK(); }