MXS-2323: Close stale connections
Cleaning up and closing stale connections to servers in maintenance mode helps administrators see when a server is no longer in use.
This commit is contained in:
parent
a7be3c527c
commit
b97976c4ee
@ -563,6 +563,17 @@ static bool server_is_shutting_down(GWBUF* writebuf)
|
||||
return err == ER_SERVER_SHUTDOWN || err == ER_NORMAL_SHUTDOWN || err == ER_SHUTDOWN_COMPLETE;
|
||||
}
|
||||
|
||||
void RWSplitSession::close_stale_connections()
|
||||
{
|
||||
for (auto& backend : m_backends)
|
||||
{
|
||||
if (backend->in_use() && !backend->can_connect())
|
||||
{
|
||||
backend->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
|
||||
{
|
||||
DCB* client_dcb = backend_dcb->session->client_dcb;
|
||||
@ -721,6 +732,15 @@ void RWSplitSession::clientReply(GWBUF* writebuf, DCB* backend_dcb)
|
||||
m_can_replay_trx = true;
|
||||
}
|
||||
|
||||
if (m_expected_responses == 0)
|
||||
{
|
||||
/**
|
||||
* Close stale connections to servers in maintenance. Done here to avoid closing the connections
|
||||
* before all responses have been received.
|
||||
*/
|
||||
close_stale_connections();
|
||||
}
|
||||
|
||||
if (backend->in_use() && backend->has_session_commands())
|
||||
{
|
||||
// Backend is still in use and has more session commands to execute
|
||||
|
@ -187,6 +187,7 @@ private:
|
||||
void continue_large_session_write(GWBUF* querybuf, uint32_t type);
|
||||
bool route_single_stmt(GWBUF* querybuf);
|
||||
bool route_stored_query();
|
||||
void close_stale_connections();
|
||||
|
||||
mxs::SRWBackend get_hinted_backend(char* name);
|
||||
mxs::SRWBackend get_slave_backend(int max_rlag);
|
||||
|
Loading…
x
Reference in New Issue
Block a user