mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-12 19:05:47 +02:00
fix(transaction): nullptr access on non transactional commands (#2724)
* fix nullptr access on non transactional commands in client tracking
This commit is contained in:
parent
12d76dd5c2
commit
95538dbad6
2 changed files with 8 additions and 2 deletions
|
@ -1187,12 +1187,12 @@ void Service::DispatchCommand(CmdArgList args, facade::ConnectionContext* cntx)
|
||||||
|
|
||||||
// if this is a read command, and client tracking has enabled,
|
// if this is a read command, and client tracking has enabled,
|
||||||
// start tracking all the updates to the keys in this read command
|
// start tracking all the updates to the keys in this read command
|
||||||
if ((cid->opt_mask() & CO::READONLY) && dfly_cntx->conn()->IsTrackingOn()) {
|
if ((cid->opt_mask() & CO::READONLY) && dfly_cntx->conn()->IsTrackingOn() &&
|
||||||
|
cid->IsTransactional()) {
|
||||||
auto cb = [&](Transaction* t, EngineShard* shard) {
|
auto cb = [&](Transaction* t, EngineShard* shard) {
|
||||||
auto keys = t->GetShardArgs(shard->shard_id());
|
auto keys = t->GetShardArgs(shard->shard_id());
|
||||||
return OpTrackKeys(t->GetOpArgs(shard), dfly_cntx, keys);
|
return OpTrackKeys(t->GetOpArgs(shard), dfly_cntx, keys);
|
||||||
};
|
};
|
||||||
|
|
||||||
dfly_cntx->transaction->Refurbish();
|
dfly_cntx->transaction->Refurbish();
|
||||||
dfly_cntx->transaction->ScheduleSingleHopT(cb);
|
dfly_cntx->transaction->ScheduleSingleHopT(cb);
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,4 +310,10 @@ TEST_F(ServerFamilyTest, ClientTrackingSelectDB) {
|
||||||
EXPECT_EQ(GetInvalidationMessage("IO0", 0).key, "C");
|
EXPECT_EQ(GetInvalidationMessage("IO0", 0).key, "C");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ServerFamilyTest, ClientTrackingNonTransactionalBug) {
|
||||||
|
Run({"HELLO", "3"});
|
||||||
|
Run({"CLIENT", "TRACKING", "ON"});
|
||||||
|
|
||||||
|
Run({"CLUSTER", "SLOTS"});
|
||||||
|
}
|
||||||
} // namespace dfly
|
} // namespace dfly
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue