fix(transaction): Reset reverse index in multi-tx (#2086)

* fix(transaction): Reset reverse index in multi-tx

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2023-10-30 17:22:35 +03:00 committed by GitHub
parent 84744a4004
commit 39c1827fa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -777,6 +777,14 @@ TEST_F(MultiTest, TestSquashing) {
done.store(true); done.store(true);
f1.Join(); f1.Join();
// Test some more unusual commands
Run({"multi"});
Run({"mget", "x1", "x2", "x3"});
Run({"mget", "x4"});
Run({"mget", "x5", "x6", "x7", "x8"});
Run({"ft.search", "i1", "*"});
Run({"exec"});
} }
TEST_F(MultiTest, MultiLeavesTxQueue) { TEST_F(MultiTest, MultiLeavesTxQueue) {

View file

@ -294,7 +294,7 @@ void Transaction::InitByKeys(KeyIndex key_index) {
// Validation. Check reverse mapping was built correctly. // Validation. Check reverse mapping was built correctly.
if (needs_reverse_mapping) { if (needs_reverse_mapping) {
for (size_t i = 0; i < args_.size(); ++i) { for (size_t i = 0; i < args_.size(); ++i) {
DCHECK_EQ(args_[i], ArgS(args, reverse_index_[i])); DCHECK_EQ(args_[i], ArgS(args, reverse_index_[i])) << args;
} }
} }
@ -393,7 +393,10 @@ void Transaction::MultiSwitchCmd(const CommandId* cid) {
unique_shard_id_ = 0; unique_shard_id_ = 0;
unique_shard_cnt_ = 0; unique_shard_cnt_ = 0;
args_.clear(); args_.clear();
reverse_index_.clear();
cid_ = cid; cid_ = cid;
cb_ptr_ = nullptr; cb_ptr_ = nullptr;
@ -1414,7 +1417,7 @@ void Transaction::CancelBlocking() {
} }
OpResult<KeyIndex> DetermineKeys(const CommandId* cid, CmdArgList args) { OpResult<KeyIndex> DetermineKeys(const CommandId* cid, CmdArgList args) {
if (cid->opt_mask() & CO::GLOBAL_TRANS) if (cid->opt_mask() & (CO::GLOBAL_TRANS | CO::NO_KEY_TRANSACTIONAL))
return KeyIndex::Empty(); return KeyIndex::Empty();
KeyIndex key_index; KeyIndex key_index;