Ignore errors sent by servers in shutdown

When a server is stopping, it'll send an error to the client before
terminating the TCP connection. The code in readwritesplit would detect
this error and create a hangup event on the DCB. This would cause it to
appear as if the TCP connection was broken and the router would
immediately try to reconnect to the same server.

By ignoring the error and allowing the connection to die on its own, we
avoid immediately reconnecting and retrying any transactions on the
stopping server. This increases the chances that the monitor will see it
first and assign the server states correctly before the transaction replay
is attempted.
This commit is contained in:
Markus Mäkelä
2018-11-23 14:12:54 +02:00
parent 9f6700b329
commit 7bf5c07835

View File

@ -586,9 +586,8 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
} }
else if (backend->get_reply_state() == REPLY_STATE_START && server_is_shutting_down(writebuf)) 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 server is shutting down, ignore this error and wait for the TCP connection to die.
// the query to be retried on another server without the client noticing it. // This allows the query to be retried on another server without the client noticing it.
poll_fake_hangup_event(backend_dcb);
gwbuf_free(writebuf); gwbuf_free(writebuf);
return; return;
} }