mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2024-12-14 11:58:02 +00: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,
|
||||
// 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 keys = t->GetShardArgs(shard->shard_id());
|
||||
return OpTrackKeys(t->GetOpArgs(shard), dfly_cntx, keys);
|
||||
};
|
||||
|
||||
dfly_cntx->transaction->Refurbish();
|
||||
dfly_cntx->transaction->ScheduleSingleHopT(cb);
|
||||
}
|
||||
|
|
|
@ -310,4 +310,10 @@ TEST_F(ServerFamilyTest, ClientTrackingSelectDB) {
|
|||
EXPECT_EQ(GetInvalidationMessage("IO0", 0).key, "C");
|
||||
}
|
||||
|
||||
TEST_F(ServerFamilyTest, ClientTrackingNonTransactionalBug) {
|
||||
Run({"HELLO", "3"});
|
||||
Run({"CLIENT", "TRACKING", "ON"});
|
||||
|
||||
Run({"CLUSTER", "SLOTS"});
|
||||
}
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Reference in a new issue