MXS-2563: Fix query retrying on slave failure

If one slave is executing a query while another one is executing a session
command and the one that is executing the session command fails, the
ongoing query would get retried even though the server that failed was not
executing it. If the server was executing a session command, nothing needs
to be done.
This commit is contained in:
Markus Mäkelä
2019-06-14 13:18:56 +03:00
parent cf866a6a57
commit f6a5b59067

View File

@ -1113,34 +1113,23 @@ bool RWSplitSession::handle_error_new_connection(DCB* backend_dcb, GWBUF* errmsg
mxb_assert(m_expected_responses > 0); mxb_assert(m_expected_responses > 0);
m_expected_responses--; m_expected_responses--;
/** // Route stored queries if this was the last server we expected a response from
* A query was sent through the backend and it is waiting for a reply. route_stored = m_expected_responses == 0;
* Try to reroute the statement to a working server or send an error
* to the client.
*/
GWBUF* stored = m_current_query.release();
if (stored && m_config.retry_failed_reads) if (!backend->has_session_commands())
{ {
mxb_assert(m_expected_responses == 0); // The backend was busy executing command and the client is expecting a response.
MXS_INFO("Re-routing failed read after server '%s' failed", backend->name()); if (m_current_query.get() && m_config.retry_failed_reads)
retry_query(stored, 0);
}
else
{
gwbuf_free(stored);
if (!backend->has_session_commands())
{ {
/** The backend was not executing a session command so the client MXS_INFO("Re-routing failed read after server '%s' failed", backend->name());
* is expecting a response. Send an error so they know to proceed. */ route_stored = false;
m_client->func.write(m_client, gwbuf_clone(errmsg)); retry_query(m_current_query.release(), 0);
} }
else
if (m_expected_responses == 0)
{ {
// This was the last response, try to route pending queries // Send an error so that the client knows to proceed.
route_stored = true; m_client->func.write(m_client, gwbuf_clone(errmsg));
m_current_query.reset();
} }
} }
} }