-
Notifications
You must be signed in to change notification settings - Fork 976
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 max_transaction_time #4135
Fix max_transaction_time #4135
Conversation
lib/MySQL_Session.cpp
Outdated
@@ -5075,6 +5078,12 @@ int MySQL_Session::handler() { | |||
handler_minus1_HandleBackendConnection(myds, myconn); | |||
} | |||
} else { | |||
if (active_transactions == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not setting this at the beginning of a query?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the beginning of a query. When rc==0
is the end of the query and when rc==-1
the query do not begin because it has failed.
What I am realizing now is that if rc==-1
because proxysql failed to retrieve the result of a query, then the number of active transaction is not going to be updated and the transaction_started_at
is not going to be reset.
transaction_started_at = 0; // reset it | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@renecannao what do you think about putting this code inside a function and calling it here and also when rc==-1
. This way, ProxySQL also reset the timer when it has an error in the middle of a transaction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to reset the timer if there is an error in the middle of a transaction?
I am going back to what I wrote before: [...] at the beginning of the query
This commit also introduces 2 output for PROXYSQL INTERNAL SESSION: - active_transactions - transaction_started_at Enhanced the TAP tests to also verify the above metrics
transaction_started_at = 0; // reset it | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to reset the timer if there is an error in the middle of a transaction?
I am going back to what I wrote before: [...] at the beginning of the query
lib/MySQL_Session.cpp
Outdated
@@ -4968,6 +4968,9 @@ int MySQL_Session::handler() { | |||
if (active_transactions == 0) | |||
transaction_started_at = 0; // reset it | |||
} | |||
} else { | |||
transaction_started_at = thread->curtime; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code means that when a query completes, and active_transactions==0
, transaction_started_at
is set to current time even if there is no transaction.
diag("Failed to get the required environmental variables."); | ||
return EXIT_FAILURE; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plan()
is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I thought it was not needed when not using ok()
IN PROXYSQL SESSION INTERNAL replace transaction_started_at with transaction_time_ms
Great, thank you @javsanpar and @renecannao! 🎉 |
Fixes #3957