From 709eeea4b1e8f9873b2e75f7d3de298bfbff1e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sun, 23 Aug 2015 17:16:44 +0000 Subject: [PATCH] Performance improvement . Issue #355 Closes #355 --- lib/MySQL_Thread.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/MySQL_Thread.cpp b/lib/MySQL_Thread.cpp index 63dfbc131..aecea6ada 100644 --- a/lib/MySQL_Thread.cpp +++ b/lib/MySQL_Thread.cpp @@ -1527,14 +1527,17 @@ void MySQL_Thread::process_all_sessions() { } for (n=0; nlen; n++) { MySQL_Session *sess=(MySQL_Session *)mysql_sessions->index(n); + unsigned int numTrx=0; unsigned long long sess_time = sess->IdleTime(); - unsigned int numTrx = sess->NumActiveTransactions(); - if (numTrx) { - // the session has idle transactions, kill it - if (sess_time/1000 > (unsigned long long)mysql_thread___max_transaction_time) sess->killed=true; - } else { - // the session is idle, kill it - if (sess_time/1000 > (unsigned long long)mysql_thread___wait_timeout) sess->killed=true; + if ( (sess_time/1000 > (unsigned long long)mysql_thread___max_transaction_time) || (sess_time/1000 > (unsigned long long)mysql_thread___wait_timeout) ) { + numTrx = sess->NumActiveTransactions(); + if (numTrx) { + // the session has idle transactions, kill it + if (sess_time/1000 > (unsigned long long)mysql_thread___max_transaction_time) sess->killed=true; + } else { + // the session is idle, kill it + if (sess_time/1000 > (unsigned long long)mysql_thread___wait_timeout) sess->killed=true; + } } if (sess->healthy==0) { unregister_session(n);