Fix readwritesplit response count assertion

The assertion in routeQuery that expects there to be at least one ongoing
query would be triggered if a query was received after a master had failed
but before the session would close. To make sure the internal logic stays
consistent, the error handler should only decrement the expected response
count if the session can continue.
This commit is contained in:
Markus Mäkelä 2019-07-17 14:45:02 +03:00
parent f8ee11cf55
commit 84f4688ebb
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -985,7 +985,6 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf,
{
// We were expecting a response but we aren't going to get one
mxb_assert(m_expected_responses > 0);
m_expected_responses--;
errmsg += " Lost connection to master server while waiting for a result.";
if (can_retry_query())
@ -1000,6 +999,14 @@ 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)