From afd2663b129b12e9bc609c8e469be943bb35f15b Mon Sep 17 00:00:00 2001 From: mwish Date: Mon, 4 Nov 2024 22:16:27 +0800 Subject: [PATCH] Bugfix for txn_write_batch creation --- 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(); }