This is an automated email from the ASF dual-hosted git repository.
maplefu pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new c01b00e6 fix(bugfix): for txn_write_batch creation (#2648)
c01b00e6 is described below
commit c01b00e61e0b913733bc2bc2b0945a9003a82aa1
Author: mwish <[email protected]>
AuthorDate: Tue Nov 5 10:18:36 2024 +0800
fix(bugfix): for txn_write_batch creation (#2648)
Co-authored-by: Twice <[email protected]>
---
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 2eead08a..234309f5 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::WriteBatchWithIndex>(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<rocksdb::WriteBatchWithIndex>(
+ /*backup_index_comparator=*/rocksdb::BytewiseComparator(),
+ /*reserved_bytes=*/0, /*overwrite_key=*/false,
/*max_bytes=*/GetWriteBatchMaxBytes());
return Status::OK();
}