MXS-1506: Fix handle_causal_read_reply

The function did not return the changed buffer to the caller of the
function.
This commit is contained in:
Markus Mäkelä
2018-04-08 08:20:20 +03:00
parent 52c55a365e
commit f124e388fa
2 changed files with 30 additions and 38 deletions

View File

@ -281,8 +281,6 @@ SRWBackend& RWSplitSession::get_backend_from_dcb(DCB *dcb)
*/ */
void RWSplitSession::correct_packet_sequence(GWBUF *buffer) void RWSplitSession::correct_packet_sequence(GWBUF *buffer)
{ {
if (m_wait_gtid_state == EXPECTING_REAL_RESULT)
{
uint8_t header[3]; uint8_t header[3];
uint32_t offset = 0; uint32_t offset = 0;
@ -290,11 +288,9 @@ void RWSplitSession::correct_packet_sequence(GWBUF *buffer)
{ {
uint32_t packet_len = MYSQL_GET_PAYLOAD_LEN(header) + MYSQL_HEADER_LEN; uint32_t packet_len = MYSQL_GET_PAYLOAD_LEN(header) + MYSQL_HEADER_LEN;
uint8_t *seq = gwbuf_byte_pointer(buffer, offset + MYSQL_SEQ_OFFSET); uint8_t *seq = gwbuf_byte_pointer(buffer, offset + MYSQL_SEQ_OFFSET);
*seq = m_next_seq; *seq = m_next_seq++;
m_next_seq++;
offset += packet_len; offset += packet_len;
} }
}
} }
static void log_unexpected_response(DCB* dcb, GWBUF* buffer) static void log_unexpected_response(DCB* dcb, GWBUF* buffer)
@ -331,13 +327,11 @@ static void log_unexpected_response(DCB* dcb, GWBUF* buffer)
} }
} }
bool RWSplitSession::handle_causal_read_reply(GWBUF *writebuf, SRWBackend& backend) GWBUF* RWSplitSession::handle_causal_read_reply(GWBUF *writebuf, SRWBackend& backend)
{ {
bool rval = true; if (m_config.enable_causal_read)
{
if (m_config.enable_causal_read && if (GWBUF_IS_REPLY_OK(writebuf) && backend == m_current_master)
GWBUF_IS_REPLY_OK(writebuf) &&
backend == m_current_master)
{ {
/** Save gtid position */ /** Save gtid position */
char *tmp = gwbuf_get_property(writebuf, (char *)"gtid"); char *tmp = gwbuf_get_property(writebuf, (char *)"gtid");
@ -349,18 +343,16 @@ bool RWSplitSession::handle_causal_read_reply(GWBUF *writebuf, SRWBackend& backe
if (m_wait_gtid_state == EXPECTING_WAIT_GTID_RESULT) if (m_wait_gtid_state == EXPECTING_WAIT_GTID_RESULT)
{ {
if ((writebuf = discard_master_wait_gtid_result(writebuf)) == NULL) writebuf = discard_master_wait_gtid_result(writebuf);
{
rval = false;
}
} }
if (rval && m_wait_gtid_state == EXPECTING_REAL_RESULT) if (writebuf && m_wait_gtid_state == EXPECTING_REAL_RESULT)
{ {
correct_packet_sequence(writebuf); correct_packet_sequence(writebuf);
} }
}
return rval; return writebuf;
} }
void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb) void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb)
@ -369,7 +361,7 @@ void RWSplitSession::clientReply(GWBUF *writebuf, DCB *backend_dcb)
SRWBackend& backend = get_backend_from_dcb(backend_dcb); SRWBackend& backend = get_backend_from_dcb(backend_dcb);
if (!handle_causal_read_reply(writebuf, backend)) if ((writebuf = handle_causal_read_reply(writebuf, backend)) == NULL)
{ {
return; // Nothing to route, return return; // Nothing to route, return
} }

View File

@ -161,7 +161,7 @@ private:
void log_master_routing_failure(bool found, mxs::SRWBackend& old_master, void log_master_routing_failure(bool found, mxs::SRWBackend& old_master,
mxs::SRWBackend& curr_master); mxs::SRWBackend& curr_master);
bool handle_causal_read_reply(GWBUF *writebuf, mxs::SRWBackend& backend); GWBUF* handle_causal_read_reply(GWBUF *writebuf, mxs::SRWBackend& backend);
GWBUF* add_prefix_wait_gtid(SERVER *server, GWBUF *origin); GWBUF* add_prefix_wait_gtid(SERVER *server, GWBUF *origin);
void correct_packet_sequence(GWBUF *buffer); void correct_packet_sequence(GWBUF *buffer);
GWBUF* discard_master_wait_gtid_result(GWBUF *buffer); GWBUF* discard_master_wait_gtid_result(GWBUF *buffer);