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 max_transaction_time #4135

Merged
merged 8 commits into from
Mar 2, 2023
9 changes: 3 additions & 6 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4968,6 +4968,9 @@ int MySQL_Session::handler() {
if (active_transactions == 0)
transaction_started_at = 0; // reset it
}
} else {
transaction_started_at = thread->curtime;
Copy link
Contributor

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.

active_transactions = NumActiveTransactions();
}

Copy link
Contributor Author

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.

Copy link
Contributor

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

handler_rc0_Process_GTID(myconn);
Expand Down Expand Up @@ -5077,12 +5080,6 @@ int MySQL_Session::handler() {
handler_minus1_HandleBackendConnection(myds, myconn);
}
} else {
if (active_transactions == 0) {
active_transactions=NumActiveTransactions();
if (active_transactions > 0) {
transaction_started_at = thread->curtime;
}
}
switch (rc) {
// rc==1 , query is still running
// start sending to frontend if mysql_thread___threshold_resultset_size is reached
Expand Down