mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
fix(server): Correctly set expiration from Lua scripts (#2080)
We used to set `time_now_ms_` only in the non-squashed execution path. Fixes #2034
This commit is contained in:
parent
474ea5137a
commit
502efd80b2
2 changed files with 18 additions and 4 deletions
|
@ -1685,16 +1685,17 @@ void Service::EvalInternal(CmdArgList args, const EvalArgs& eval_args, Interpret
|
||||||
});
|
});
|
||||||
|
|
||||||
++ServerState::tlocal()->stats.eval_shardlocal_coordination_cnt;
|
++ServerState::tlocal()->stats.eval_shardlocal_coordination_cnt;
|
||||||
boost::intrusive_ptr<Transaction> stub_tx = new Transaction{tx, *sid};
|
|
||||||
cntx->transaction = stub_tx.get();
|
|
||||||
|
|
||||||
tx->PrepareMultiForScheduleSingleHop(*sid, tx->GetDbIndex(), args);
|
tx->PrepareMultiForScheduleSingleHop(*sid, tx->GetDbIndex(), args);
|
||||||
tx->ScheduleSingleHop([&](Transaction*, EngineShard*) {
|
tx->ScheduleSingleHop([&](Transaction*, EngineShard*) {
|
||||||
|
boost::intrusive_ptr<Transaction> stub_tx = new Transaction{tx, *sid};
|
||||||
|
cntx->transaction = stub_tx.get();
|
||||||
|
|
||||||
result = interpreter->RunFunction(eval_args.sha, &error);
|
result = interpreter->RunFunction(eval_args.sha, &error);
|
||||||
|
|
||||||
|
cntx->transaction = tx;
|
||||||
return OpStatus::OK;
|
return OpStatus::OK;
|
||||||
});
|
});
|
||||||
|
|
||||||
cntx->transaction = tx;
|
|
||||||
if (*sid != ServerState::tlocal()->thread_index()) {
|
if (*sid != ServerState::tlocal()->thread_index()) {
|
||||||
VLOG(1) << "Migrating connection " << cntx->conn() << " from " << ProactorBase::GetIndex()
|
VLOG(1) << "Migrating connection " << cntx->conn() << " from " << ProactorBase::GetIndex()
|
||||||
<< " to " << *sid;
|
<< " to " << *sid;
|
||||||
|
|
|
@ -876,6 +876,19 @@ TEST_F(MultiTest, TestLockedKeys) {
|
||||||
EXPECT_FALSE(service_->IsLocked(0, "key2"));
|
EXPECT_FALSE(service_->IsLocked(0, "key2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MultiTest, EvalExpiration) {
|
||||||
|
// Make sure expiration is correctly set even from Lua scripts
|
||||||
|
if (auto config = absl::GetFlag(FLAGS_default_lua_flags); config != "") {
|
||||||
|
GTEST_SKIP() << "Skipped Eval test because default_lua_flags is set";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
absl::FlagSaver fs;
|
||||||
|
absl::SetFlag(&FLAGS_multi_exec_mode, Transaction::LOCK_AHEAD);
|
||||||
|
Run({"eval", "redis.call('set', 'x', 0, 'ex', 5, 'nx')", "1", "x"});
|
||||||
|
EXPECT_LE(CheckedInt({"pttl", "x"}), 5000);
|
||||||
|
}
|
||||||
|
|
||||||
class MultiEvalTest : public BaseFamilyTest {
|
class MultiEvalTest : public BaseFamilyTest {
|
||||||
protected:
|
protected:
|
||||||
MultiEvalTest() : BaseFamilyTest() {
|
MultiEvalTest() : BaseFamilyTest() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue