From b07ffdb2fad57704ba0e3dcb7085a719b0495bb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 26 Jul 2019 09:34:08 +0300 Subject: [PATCH] Fix hang on transaction replay The expected response counter was not decremented if a transaction replay was started. This caused the connections to hang which in turn caused the failure of the mxs1507_trx_stress test case. --- .../routing/readwritesplit/rwsplitsession.cc | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index fc1faaf13..fb4ee458b 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -963,7 +963,9 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf, MXS_INFO("Master '%s' failed: %s", backend->name(), extract_error(errmsgbuf).c_str()); /** The connection to the master has failed */ - if (!backend->is_waiting_result()) + bool expected_response = backend->is_waiting_result(); + + if (!expected_response) { /** The failure of a master is not considered a critical * failure as partial functionality still remains. If @@ -999,14 +1001,6 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf, can_continue = true; send_readonly_error(m_client); } - - // Decrement the expected response count only if we know we can continue the sesssion. - // This keeps the internal logic sound even if another query is routed before the session - // is closed. - if (can_continue) - { - m_expected_responses--; - } } if (session_trx_is_active(session) && m_otrx_state == OTRX_INACTIVE) @@ -1034,6 +1028,14 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf, } } + // Decrement the expected response count only if we know we can continue the sesssion. + // This keeps the internal logic sound even if another query is routed before the session + // is closed. + if (can_continue && expected_response) + { + m_expected_responses--; + } + backend->close(); backend->set_close_reason("Master connection failed: " + extract_error(errmsgbuf)); }