Merge branch '2.3' into develop

This commit is contained in:
Markus Mäkelä
2019-01-16 16:26:00 +02:00
13 changed files with 141 additions and 94 deletions

View File

@ -417,3 +417,12 @@ mxs::PRWBackends::iterator find_best_backend(mxs::PRWBackends& backends,
* The following are implemented in rwsplit_tmp_table_multi.c
*/
void close_all_connections(mxs::PRWBackends& backends);
/**
* Utility function for extracting error messages from buffers
*
* @param buffer Buffer containing an error
*
* @return String representation of the error
*/
std::string extract_error(GWBUF* buffer);

View File

@ -449,6 +449,7 @@ bool RWSplitSession::route_session_write(GWBUF* querybuf, uint8_t command, uint3
}
else if (qc_query_is_type(type, QUERY_TYPE_DEALLOC_PREPARE))
{
mxb_assert(!mxs_mysql_is_ps_command(m_qc.current_route_info().command()));
m_qc.ps_erase(querybuf);
}

View File

@ -29,19 +29,24 @@ using namespace maxscale;
*/
static std::string extract_error(GWBUF* buffer)
std::string extract_error(GWBUF* buffer)
{
std::string rval;
if (MYSQL_IS_ERROR_PACKET(((uint8_t*)GWBUF_DATA(buffer))))
{
size_t replylen = MYSQL_GET_PAYLOAD_LEN(GWBUF_DATA(buffer));
size_t replylen = MYSQL_GET_PAYLOAD_LEN(GWBUF_DATA(buffer)) + MYSQL_HEADER_LEN;
char replybuf[replylen];
gwbuf_copy_data(buffer, 0, sizeof(replybuf), (uint8_t*)replybuf);
std::string err;
std::string msg;
err.append(replybuf + 8, 5);
msg.append(replybuf + 13, replylen - 4 - 5);
/**
* The payload starts with a one byte command followed by a two byte error code, a six byte state and
* a human-readable string that spans the rest of the packet.
*/
err.append(replybuf + MYSQL_HEADER_LEN + 3, 6);
msg.append(replybuf + MYSQL_HEADER_LEN + 3 + 6, replylen - MYSQL_HEADER_LEN - 3 - 6);
rval = err + ": " + msg;
}

View File

@ -941,7 +941,10 @@ void RWSplitSession::handleError(GWBUF* errmsgbuf,
}
else
{
MXS_ERROR("Lost connection to the master server, closing session.%s", errmsg.c_str());
int64_t idle = mxs_clock() - backend->dcb()->last_read;
MXS_ERROR("Lost connection to the master server, closing session.%s "
"Connection has been idle for %.1f seconds. Error caused by: %s",
errmsg.c_str(), (float)idle / 10.f, extract_error(errmsgbuf).c_str());
}
}