Acknowledge one-way commands immediately
The Backend class response state tracking was not updated when a one-way command was executed. This caused the logic in handleError to break if a master was executing a command that wouldn't create a response.
This commit is contained in:
@ -403,6 +403,10 @@ 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",
|
||||
@ -1006,19 +1010,28 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, SRWBackend& target, bool
|
||||
atomic_add_uint64(&m_router->stats().n_queries, 1);
|
||||
atomic_add_uint64(&target->server()->stats.packets, 1);
|
||||
|
||||
if (!m_qc.large_query() && response == mxs::Backend::EXPECT_RESPONSE)
|
||||
if (!m_qc.large_query())
|
||||
{
|
||||
/** The server will reply to this command */
|
||||
ss_dassert(target->get_reply_state() == REPLY_STATE_DONE);
|
||||
target->set_reply_state(REPLY_STATE_START);
|
||||
m_expected_responses++;
|
||||
|
||||
if (m_qc.load_data_state() == QueryClassifier::LOAD_DATA_END)
|
||||
if (response == mxs::Backend::EXPECT_RESPONSE)
|
||||
{
|
||||
/** The final packet in a LOAD DATA LOCAL INFILE is an empty packet
|
||||
* to which the server responds with an OK or an ERR packet */
|
||||
ss_dassert(gwbuf_length(querybuf) == 4);
|
||||
m_qc.set_load_data_state(QueryClassifier::LOAD_DATA_INACTIVE);
|
||||
/** The server will reply to this command */
|
||||
target->set_reply_state(REPLY_STATE_START);
|
||||
m_expected_responses++;
|
||||
|
||||
if (m_qc.load_data_state() == QueryClassifier::LOAD_DATA_END)
|
||||
{
|
||||
/** The final packet in a LOAD DATA LOCAL INFILE is an empty packet
|
||||
* to which the server responds with an OK or an ERR packet */
|
||||
ss_dassert(gwbuf_length(querybuf) == 4);
|
||||
m_qc.set_load_data_state(QueryClassifier::LOAD_DATA_INACTIVE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The server won't respond, mark it as done
|
||||
target->ack_write();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user