1
0
Fork 0
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:
Kostas Kyrimis 2024-03-14 10:07:24 +02:00 committed by GitHub
parent 12d76dd5c2
commit 95538dbad6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View file

@ -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);
}

View file

@ -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