MXS-2564: Reconnect only when necessary
By doing the reconnection only when a new query arrives, we prevent the excessive reconnecting that is done when a server's actual and monitored states are in conflict.
This commit is contained in:
@ -1175,39 +1175,16 @@ bool RWSplitSession::handle_error_new_connection(DCB* backend_dcb, GWBUF* errmsg
|
|||||||
route_stored_query();
|
route_stored_query();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool succp = false;
|
bool ok = can_recover_servers() || have_open_connections();
|
||||||
/**
|
|
||||||
* Try to get replacement slave or at least the minimum
|
|
||||||
* number of slave connections for router session.
|
|
||||||
*/
|
|
||||||
if (m_recv_sescmd > 0 && m_config.disable_sescmd_history)
|
|
||||||
{
|
|
||||||
for (const auto& a : m_backends)
|
|
||||||
{
|
|
||||||
if (a->in_use())
|
|
||||||
{
|
|
||||||
succp = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!succp)
|
if (!ok)
|
||||||
{
|
|
||||||
MXS_ERROR("Unable to continue session as all connections have failed, "
|
|
||||||
"last server to fail was '%s'.", backend->name());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
succp = m_router->select_connect_backend_servers(ses,
|
MXS_ERROR("Unable to continue session as all connections have failed and "
|
||||||
m_backends,
|
"new connections cannot be created. Last server to fail was '%s'.",
|
||||||
m_current_master,
|
backend->name());
|
||||||
&m_sescmd_list,
|
|
||||||
&m_expected_responses,
|
|
||||||
connection_type::SLAVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return succp;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,6 +293,14 @@ private:
|
|||||||
return !m_config.disable_sescmd_history || m_recv_sescmd == 0;
|
return !m_config.disable_sescmd_history || m_recv_sescmd == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool have_open_connections() const
|
||||||
|
{
|
||||||
|
return std::any_of(
|
||||||
|
m_backends.begin(), m_backends.end(), [](const mxs::SRWBackend& b) {
|
||||||
|
return b->in_use();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
inline bool is_large_query(GWBUF* buf)
|
inline bool is_large_query(GWBUF* buf)
|
||||||
{
|
{
|
||||||
uint32_t buflen = gwbuf_length(buf);
|
uint32_t buflen = gwbuf_length(buf);
|
||||||
|
Reference in New Issue
Block a user