MXS-1507: Use same mechanism for all delayed routing

Passing the delay to the retry_query function allows the same function to
be used in all cases. This removes duplicate code.
This commit is contained in:
Markus Mäkelä 2018-04-19 15:25:14 +03:00
parent 92e0b944a9
commit daecb6980b
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 4 additions and 5 deletions

View File

@ -109,12 +109,12 @@ bool RWSplitSession::prepare_target(SRWBackend& target, route_target_t route_tar
return rval;
}
void RWSplitSession::retry_query(GWBUF* querybuf)
void RWSplitSession::retry_query(GWBUF* querybuf, int delay)
{
ss_dassert(querybuf);
// Try to route the query again later
MXS_SESSION* session = m_client->session;
session_delay_routing(session, router_as_downstream(session), querybuf, 1);
session_delay_routing(session, router_as_downstream(session), querybuf, delay);
++m_retry_duration;
}

View File

@ -641,8 +641,7 @@ bool RWSplitSession::handle_error_new_connection(DCB *backend_dcb, GWBUF *errmsg
if (stored && m_config.retry_failed_reads)
{
MXS_INFO("Re-routing failed read after server '%s' failed", backend->name());
MXS_SESSION* session = m_client->session;
session_delay_routing(session, router_as_downstream(session), stored, 0);
retry_query(stored, 0);
}
else
{

View File

@ -163,7 +163,7 @@ private:
bool handle_got_target(GWBUF* querybuf, mxs::SRWBackend& target, bool store);
void handle_connection_keepalive(mxs::SRWBackend& target);
bool prepare_target(mxs::SRWBackend& target, route_target_t route_target);
void retry_query(GWBUF* querybuf);
void retry_query(GWBUF* querybuf, int delay = 1);
bool should_replace_master(mxs::SRWBackend& target);
void replace_master(mxs::SRWBackend& target);