MXS-2144: Treat server shutdown as a network error
If the server where a query is being executed is shutting down, readwritesplit should treat it as an error to make retrying of the query possible. By treating server shutdowns as network errors, the same code path that is used for actual network errors can be taken. This removes the need for any extra retrying logic for this particular case.
This commit is contained in:
@ -555,6 +555,12 @@ void RWSplitSession::manage_transactions(SRWBackend& backend, GWBUF* writebuf)
|
||||
}
|
||||
}
|
||||
|
||||
static bool server_is_shutting_down(GWBUF* writebuf)
|
||||
{
|
||||
uint64_t err = mxs_mysql_get_mysql_errno(writebuf);
|
||||
return err == ER_SERVER_SHUTDOWN || err == ER_NORMAL_SHUTDOWN || err == ER_SHUTDOWN_COMPLETE;
|
||||
}
|
||||
|
||||
void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
|
||||
{
|
||||
DCB* client_dcb = backend_dcb->session->client_dcb;
|
||||
@ -578,6 +584,14 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (backend->get_reply_state() == REPLY_STATE_START && server_is_shutting_down(writebuf))
|
||||
{
|
||||
// The server is shutting down, act as if the network connection failed. This allows
|
||||
// the query to be retried on another server without the client noticing it.
|
||||
poll_fake_hangup_event(backend_dcb);
|
||||
gwbuf_free(writebuf);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((writebuf = handle_causal_read_reply(writebuf, backend)) == NULL)
|
||||
{
|
||||
|
Reference in New Issue
Block a user