mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-10 18:05:44 +02:00
fix: lua and client tracking (#3163)
* add missing tracking_cb_ invkoe in RunSquashedMultiCb * add test
This commit is contained in:
parent
007d4854db
commit
7f9a13bb50
3 changed files with 26 additions and 3 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <absl/strings/match.h>
|
||||
|
||||
#include "absl/strings/str_cat.h"
|
||||
#include "base/gtest.h"
|
||||
#include "base/logging.h"
|
||||
#include "facade/facade_test.h"
|
||||
|
@ -447,4 +448,21 @@ TEST_F(ServerFamilyTest, ClientTrackingNonTransactionalBug) {
|
|||
|
||||
Run({"CLUSTER", "SLOTS"});
|
||||
}
|
||||
|
||||
TEST_F(ServerFamilyTest, ClientTrackingLuaBug) {
|
||||
Run({"HELLO", "3"});
|
||||
// Check stickiness
|
||||
Run({"CLIENT", "TRACKING", "ON"});
|
||||
using namespace std::string_literals;
|
||||
std::string eval = R"(redis.call('get', 'foo'); redis.call('set', 'foo', 'bar'); )";
|
||||
Run({"EVAL", absl::StrCat(eval, "return 1"), "1", "foo"});
|
||||
Run({"PING"});
|
||||
|
||||
EXPECT_EQ(InvalidationMessagesLen("IO0"), 1);
|
||||
absl::StrAppend(&eval, R"(redis.call('get', 'oof'); redis.call('set', 'oof', 'bar'); return 1)");
|
||||
Run({"EVAL", eval, "2", "foo", "oof"});
|
||||
Run({"PING"});
|
||||
EXPECT_EQ(InvalidationMessagesLen("IO0"), 3);
|
||||
}
|
||||
|
||||
} // namespace dfly
|
||||
|
|
|
@ -665,9 +665,7 @@ void Transaction::RunCallback(EngineShard* shard) {
|
|||
// Log to journal only once the command finished running
|
||||
if ((coordinator_state_ & COORD_CONCLUDING) || (multi_ && multi_->concluding)) {
|
||||
LogAutoJournalOnShard(shard, result);
|
||||
if (tracking_cb_) {
|
||||
tracking_cb_(this);
|
||||
}
|
||||
MaybeInvokeTrackingCb();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1252,6 +1250,7 @@ OpStatus Transaction::RunSquashedMultiCb(RunnableType cb) {
|
|||
auto result = cb(this, shard);
|
||||
shard->db_slice().OnCbFinish();
|
||||
LogAutoJournalOnShard(shard, result);
|
||||
MaybeInvokeTrackingCb();
|
||||
|
||||
DCHECK_EQ(result.flags, 0); // if it's sophisticated, we shouldn't squash it
|
||||
return result;
|
||||
|
|
|
@ -364,6 +364,12 @@ class Transaction {
|
|||
tracking_cb_ = std::move(f);
|
||||
}
|
||||
|
||||
void MaybeInvokeTrackingCb() {
|
||||
if (tracking_cb_) {
|
||||
tracking_cb_(this);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove once BZPOP is stabilized
|
||||
std::string DEBUGV18_BlockInfo() {
|
||||
return "claimed=" + std::to_string(blocking_barrier_.IsClaimed()) +
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue