MXS-1503: Queue command if executing a session command

When a non-connected target is chosed as the target server and the session
command history is not empty, the query needs to be placed into the query
queue and routed only after the session commands have been executed.
This commit is contained in:
Markus Mäkelä
2018-03-28 16:26:46 +03:00
parent e57ac4b0a3
commit 7f0745e552
2 changed files with 28 additions and 26 deletions

View File

@ -1272,11 +1272,15 @@ static void clientReply(MXS_ROUTER *instance,
process_sescmd_response(rses, backend, &writebuf);
}
bool queue_routed = false;
if (rses->expected_responses == 0 && rses->query_queue)
if (backend->session_command_count())
{
if (backend->execute_session_command())
{
rses->expected_responses++;
}
}
else if (rses->expected_responses == 0 && rses->query_queue)
{
queue_routed = true;
route_stored_query(rses);
}
@ -1286,17 +1290,6 @@ static void clientReply(MXS_ROUTER *instance,
/** Write reply to client DCB */
MXS_SESSION_ROUTE_REPLY(backend_dcb->session, writebuf);
}
/** Check pending session commands */
else if (!queue_routed && backend->session_command_count())
{
MXS_DEBUG("Backend %s processed reply and starts to execute active cursor.",
backend->uri());
if (backend->execute_session_command())
{
rses->expected_responses++;
}
}
}