MXS-1506: Allow immediate query re-routing
Now that the readwritesplit uses the same mechanism for both retry_failed_reads and delayed query retries, the re-routing function should accept a delay of 0 seconds. This makes the mechanism more suitable for other uses e.g. delaying of queries in filters.
This commit is contained in:
@ -633,7 +633,7 @@ session_dump_statements_t session_get_dump_statements();
|
||||
* @param session The current Session
|
||||
* @param down The downstream component, either a filter or a router
|
||||
* @param buffer The buffer to route
|
||||
* @param seconds Number of seconds to wait before routing the query
|
||||
* @param seconds Number of seconds to wait before routing the query. Use 0 for immediate re-routing.
|
||||
*
|
||||
* @return True if queuing of the query was successful
|
||||
*/
|
||||
|
@ -1394,16 +1394,23 @@ bool session_delay_routing(MXS_SESSION* session, MXS_DOWNSTREAM down, GWBUF* buf
|
||||
|
||||
try
|
||||
{
|
||||
std::stringstream name;
|
||||
name << "Session_" << session->ses_id << "_retry";
|
||||
|
||||
Worker* worker = Worker::get_current();
|
||||
ss_dassert(worker == Worker::get(session->client_dcb->poll.thread.id));
|
||||
std::auto_ptr<DelayedRoutingTask> task(new DelayedRoutingTask(session, down, buffer));
|
||||
std::auto_ptr<TaskAssignment> job(new TaskAssignment(task, worker));
|
||||
TaskAssignment* pJob = job.release();
|
||||
|
||||
hktask_add(name.str().c_str(), delayed_routing_cb, pJob, seconds);
|
||||
if (seconds == 0)
|
||||
{
|
||||
// No actual delay, just re-route query
|
||||
worker->post(task);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::stringstream name;
|
||||
name << "Session_" << session->ses_id << "_retry";
|
||||
std::auto_ptr<TaskAssignment> job(new TaskAssignment(task, worker));
|
||||
hktask_add(name.str().c_str(), delayed_routing_cb, job.release(), seconds);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
catch (std::bad_alloc)
|
||||
|
@ -615,7 +615,7 @@ bool RWSplitSession::handle_error_new_connection(DCB *backend_dcb, GWBUF *errmsg
|
||||
{
|
||||
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, 1);
|
||||
session_delay_routing(session, router_as_downstream(session), stored, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user