MXS-1938: Log query for inconsistent replies
If a session command produces a different result on the slave than it did on the master, a warning is logged. This warning now also logs the query that was being executed to make investigation of the problem easier.
This commit is contained in:
@ -71,6 +71,11 @@ std::string SessionCommand::to_string()
|
|||||||
/** TODO: Create C++ versions of modutil functions */
|
/** TODO: Create C++ versions of modutil functions */
|
||||||
GWBUF *buf = m_buffer.release();
|
GWBUF *buf = m_buffer.release();
|
||||||
|
|
||||||
|
if (!GWBUF_IS_CONTIGUOUS(buf))
|
||||||
|
{
|
||||||
|
buf = gwbuf_make_contiguous(buf);
|
||||||
|
}
|
||||||
|
|
||||||
if (modutil_extract_SQL(buf, &sql, &sql_len))
|
if (modutil_extract_SQL(buf, &sql, &sql_len))
|
||||||
{
|
{
|
||||||
str.append(sql, sql_len);
|
str.append(sql, sql_len);
|
||||||
|
|||||||
@ -55,16 +55,20 @@ static std::string extract_error(GWBUF* buffer)
|
|||||||
*
|
*
|
||||||
* @return True if the responses were different and connection was discarded
|
* @return True if the responses were different and connection was discarded
|
||||||
*/
|
*/
|
||||||
static bool discard_if_response_differs(SRWBackend backend, uint8_t master_cmd, uint8_t slave_cmd)
|
static bool discard_if_response_differs(SRWBackend backend, uint8_t master_response,
|
||||||
|
uint8_t slave_response, mxs::SSessionCommand sescmd)
|
||||||
{
|
{
|
||||||
bool rval = false;
|
bool rval = false;
|
||||||
|
|
||||||
if (master_cmd != slave_cmd)
|
if (master_response != slave_response)
|
||||||
{
|
{
|
||||||
|
uint8_t cmd = sescmd->get_command();
|
||||||
|
std::string query = sescmd->to_string();
|
||||||
MXS_WARNING("Slave server '%s': response (0x%02hhx) differs "
|
MXS_WARNING("Slave server '%s': response (0x%02hhx) differs "
|
||||||
"from master's response(0x%02hhx). Closing slave "
|
"from master's response (0x%02hhx) to %s: `%s`. "
|
||||||
"connection due to inconsistent session state.",
|
"Closing slave connection due to inconsistent session state.",
|
||||||
backend->name(), slave_cmd, master_cmd);
|
backend->name(), slave_response, master_response, STRPACKETTYPE(cmd),
|
||||||
|
query.empty() ? "<no query>" : query.c_str());
|
||||||
backend->close(mxs::Backend::CLOSE_FATAL);
|
backend->close(mxs::Backend::CLOSE_FATAL);
|
||||||
rval = true;
|
rval = true;
|
||||||
}
|
}
|
||||||
@ -83,6 +87,7 @@ void process_sescmd_response(RWSplitSession* rses, SRWBackend& backend,
|
|||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
gwbuf_copy_data(*ppPacket, MYSQL_HEADER_LEN, 1, &cmd);
|
gwbuf_copy_data(*ppPacket, MYSQL_HEADER_LEN, 1, &cmd);
|
||||||
uint8_t command = backend->next_session_command()->get_command();
|
uint8_t command = backend->next_session_command()->get_command();
|
||||||
|
mxs::SSessionCommand sescmd = backend->next_session_command();
|
||||||
uint64_t id = backend->complete_session_command();
|
uint64_t id = backend->complete_session_command();
|
||||||
MXS_PS_RESPONSE resp = {};
|
MXS_PS_RESPONSE resp = {};
|
||||||
bool discard = true;
|
bool discard = true;
|
||||||
@ -124,7 +129,7 @@ void process_sescmd_response(RWSplitSession* rses, SRWBackend& backend,
|
|||||||
for (SlaveResponseList::iterator it = rses->slave_responses.begin();
|
for (SlaveResponseList::iterator it = rses->slave_responses.begin();
|
||||||
it != rses->slave_responses.end(); it++)
|
it != rses->slave_responses.end(); it++)
|
||||||
{
|
{
|
||||||
if (discard_if_response_differs(it->first, cmd, it->second))
|
if (discard_if_response_differs(it->first, cmd, it->second, sescmd))
|
||||||
{
|
{
|
||||||
*pReconnect = true;
|
*pReconnect = true;
|
||||||
}
|
}
|
||||||
@ -139,7 +144,7 @@ void process_sescmd_response(RWSplitSession* rses, SRWBackend& backend,
|
|||||||
rses->slave_responses.push_back(std::make_pair(backend, cmd));
|
rses->slave_responses.push_back(std::make_pair(backend, cmd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (discard_if_response_differs(backend, rses->sescmd_responses[id], cmd))
|
else if (discard_if_response_differs(backend, rses->sescmd_responses[id], cmd, sescmd))
|
||||||
{
|
{
|
||||||
*pReconnect = true;
|
*pReconnect = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user