From dbdfec349475255185ae409320a8e027167cee6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jaramago=20Fern=C3=A1ndez?= Date: Sat, 13 Aug 2022 09:02:53 +0200 Subject: [PATCH] Add 'ASYNC_IDLE' precondition for connections considered for expiring If any scenario is found in which we may want to consider a non 'ASYNC_IDLE' connection for expiring, this precondition shall be removed, and checks should be responsible for ensuring 'ASYNC_IDLE' state in the connection. --- lib/MySQL_Session.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_Session.cpp b/lib/MySQL_Session.cpp index fd0b1de22..a33860ed6 100644 --- a/lib/MySQL_Session.cpp +++ b/lib/MySQL_Session.cpp @@ -697,9 +697,10 @@ void MySQL_Session::update_expired_conns(const vectorIsActiveTransaction(); const bool multiplex_disabled = myconn->MultiplexDisabled(false); + const bool is_idle = myconn->async_state_machine == ASYNC_IDLE; // Make sure the connection is reusable before performing any check - if (myconn->reusable==true && is_active_transaction==false && multiplex_disabled==false) { + if (myconn->reusable==true && is_active_transaction==false && multiplex_disabled==false && is_idle) { for (const function& check : checks) { if (check(myconn)) { this->hgs_expired_conns.push_back(mybe->hostgroup_id);