Fix debug assert on reconnection with session commands

When a query was routed to a server that must first be connected to, the
expected response count was not updated for the executed session commands.
This commit is contained in:
Markus Mäkelä 2018-06-13 10:41:23 +03:00
parent 9dd8043359
commit 3ed6411741
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
4 changed files with 12 additions and 11 deletions

View File

@ -96,6 +96,7 @@ bool Backend::execute_session_command()
{
case MXS_COM_QUIT:
case MXS_COM_STMT_CLOSE:
case MXS_COM_STMT_SEND_LONG_DATA:
/** These commands do not generate responses */
rval = write(buffer, NO_RESPONSE);
complete_session_command();

View File

@ -92,7 +92,7 @@ public:
*/
bool continue_write(GWBUF* buffer)
{
return mxs::Backend::write(buffer);
return mxs::Backend::write(buffer, Backend::NO_RESPONSE);
}
void close(close_type type = CLOSE_NORMAL);

View File

@ -117,6 +117,15 @@ bool RWSplitSession::prepare_target(SRWBackend& target, route_target_t route_tar
ss_dassert(target->can_connect() && can_recover_servers());
ss_dassert(!TARGET_IS_MASTER(route_target) || m_config.master_reconnection);
rval = target->connect(m_client->session, &m_sescmd_list);
MXS_INFO("Connected to '%s'", target->name());
if (rval && target->is_waiting_result())
{
ss_info_dassert(!m_sescmd_list.empty() && target->has_session_commands(),
"Session command list must not be empty and target "
"should have unfinished session commands.");
m_expected_responses++;
}
}
return rval;
@ -403,10 +412,6 @@ bool RWSplitSession::route_session_write(GWBUF *querybuf, uint8_t command, uint3
{
m_expected_responses++;
}
else
{
backend->ack_write();
}
MXS_INFO("Route query to %s: %s \t%s",
backend->is_master() ? "master" : "slave",
@ -1028,11 +1033,6 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, SRWBackend& target, bool
m_qc.set_load_data_state(QueryClassifier::LOAD_DATA_INACTIVE);
}
}
else
{
// The server won't respond, mark it as done
target->ack_write();
}
}
m_qc.set_large_query(large_query);

View File

@ -553,7 +553,7 @@ void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb)
if (backend->has_session_commands())
{
if (backend->execute_session_command())
if (backend->execute_session_command() && backend->is_waiting_result())
{
m_expected_responses++;
}