Skip to content

Commit 4f70d1b

Browse files
fix(transaction): Fix auto journaling in transaction (#4737)
* fix(transaction): Fix auto journaling in transaction Signed-off-by: Stepan Bagritsevich <[email protected]> * refactor: address comments Signed-off-by: Stepan Bagritsevich <[email protected]> --------- Signed-off-by: Stepan Bagritsevich <[email protected]>
1 parent 2ff8603 commit 4f70d1b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/server/transaction.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ void Transaction::MultiSwitchCmd(const CommandId* cid) {
499499
kv_fp_.clear();
500500

501501
cid_ = cid;
502+
re_enabled_auto_journal_ = false;
502503
cb_ptr_ = nullptr;
503504

504505
for (auto& sd : shard_data_) {

tests/dragonfly/replication_test.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ async def is_match_rsp(rx):
589589
async def skip_cmd():
590590
await is_match_rsp(r".*")
591591

592+
async def skip_cmds(n):
593+
for _ in range(n):
594+
await skip_cmd()
595+
592596
async def check(cmd, rx):
593597
await c_master.execute_command(cmd)
594598
match = await is_match_rsp(rx)
@@ -731,6 +735,21 @@ async def check_expire(key):
731735
)
732736
await check_expire("renamekey")
733737

738+
# Test autojournaling in the multi-mode
739+
await c_master.execute_command("XADD k-stream * field value")
740+
await c_master.execute_command("SADD k-one-element-set value1 value2")
741+
sha = await c_master.script_load(
742+
"redis.call('XTRIM', KEYS[1], 'MINID', '0'); return redis.call('SPOP', KEYS[2]);"
743+
)
744+
await skip_cmds(3)
745+
# The first call to XTRIM triggers autojournaling.
746+
# The SPOP command is executed with CO::NO_AUTOJOURNALING.
747+
# This test ensures that the SPOP command is still properly replicated
748+
await check_list_ooo(
749+
f"EVALSHA {sha} 2 k-stream k-one-element-set",
750+
[r"XTRIM k-stream MINID 0", r"SREM k-one-element-set value[12]"],
751+
)
752+
734753

735754
"""
736755
Test automatic replication of expiry.

0 commit comments

Comments
 (0)