Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): Init tx time for all multi/lua transactions #2562

Merged
merged 3 commits into from
Feb 8, 2024
Merged

Conversation

chakaz
Copy link
Collaborator

@chakaz chakaz commented Feb 7, 2024

Fixes #2555

@chakaz chakaz requested a review from adiholden February 7, 2024 19:37
kostasrim
kostasrim previously approved these changes Feb 8, 2024
if (cntx->transaction) {
// This will be 0 if run under an unscheduled transaction
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how come we run under unscheduled transaction?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this transaction has no keys, see #2555 (comment):

EVAL "return redis.call('TIME')" 0

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roman, your comment made me rethink my solution. Now I explicitly init tx time in all cases, including empty keys multi/lua. PTAL.

@chakaz chakaz changed the title fix(server): Return correct TIME under unscheduled tx fix(server): Init tx time for all multi/lua transactions Feb 8, 2024
@@ -1710,8 +1710,10 @@ optional<bool> StartMultiEval(DbIndex dbid, CmdArgList keys, ScriptMgr::ScriptPa
return false;
}

if (keys.empty() && script_mode == Transaction::LOCK_AHEAD)
if (keys.empty() && script_mode == Transaction::LOCK_AHEAD) {
trans->InitTxTime();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do we call InitTxTime for NON_ATOMIC mode and keys is empty?

@@ -2040,7 +2042,9 @@ void Service::Exec(CmdArgList args, ConnectionContext* cntx) {
"Dragonfly does not allow execution of a server-side Lua in Multi transaction");

bool scheduled = false;
if (*multi_mode != Transaction::NOT_DETERMINED) {
if (*multi_mode == Transaction::NOT_DETERMINED) {
cntx->transaction->InitTxTime();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about call this in transaction constructor and if we will do scheduling this will overide the value

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fantastic idea!

@chakaz chakaz requested a review from adiholden February 8, 2024 12:07
@chakaz chakaz merged commit 9912df0 into main Feb 8, 2024
10 checks passed
@chakaz chakaz deleted the lua-time branch February 8, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EVAL "return redis.call('TIME')" 0 returning zeros
4 participants