bug(replication): BLPOP fix write to shard journal of popped key (#761)

Signed-off-by: adi_holden <adi@dragonflydb.io>
This commit is contained in:
adiholden 2023-02-06 10:04:48 +02:00 committed by GitHub
parent 69bca570f0
commit cc74594c2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View file

@ -290,11 +290,6 @@ OpStatus BPopper::Run(Transaction* t, unsigned msec) {
auto cb = [this](Transaction* t, EngineShard* shard) {
Pop(t, shard);
OpArgs op_args = t->GetOpArgs(shard);
if (op_args.shard->journal()) {
string command = dir_ == ListDir::LEFT ? "LPOP" : "RPOP";
RecordJournal(op_args, command, ArgSlice{key_}, 1);
}
return OpStatus::OK;
};
t->Execute(std::move(cb), true);
@ -317,6 +312,11 @@ void BPopper::Pop(Transaction* t, EngineShard* shard) {
if (quicklistCount(ql) == 0) {
CHECK(shard->db_slice().Del(t->GetDbIndex(), it));
}
OpArgs op_args = t->GetOpArgs(shard);
if (op_args.shard->journal()) {
string command = dir_ == ListDir::LEFT ? "LPOP" : "RPOP";
RecordJournal(op_args, command, ArgSlice{key_}, 1);
}
}
}

View file

@ -520,10 +520,10 @@ async def test_rewrites(df_local_factory):
# Check there is no rewrite for RPOPLPUSH on single shard
await check("RPOPLPUSH list list", r"RPOPLPUSH list list")
# Check BRPOPLPUSH on single shard turns into RPOPLPUSH
await check("BRPOPLPUSH list list 0", r"RPOPLPUSH list list")
# Check BRPOPLPUSH on single shard turns into LMOVE
await check("BRPOPLPUSH list list 0", r"LMOVE list list RIGHT LEFT")
# Check BLPOP turns into LPOP
await check("BLPOP list 0", r"LPOP list")
await check("BLPOP list list1 0", r"LPOP list")
# Check BRPOP turns into RPOP
await check("BRPOP list 0", r"RPOP list")