Log low-level reason and idle time on master failure

If the connection to the master is lost, knowing what type of an error
caused the call to handleError helps deduce what was the real reason for
it. Logging the idle time of the connection helps detect when the
wait_timeout of a connection is exceeded.
This commit is contained in:
Markus Mäkelä
2019-01-14 13:14:20 +02:00
parent 8cef8b9472
commit 021d48f94c
4 changed files with 16 additions and 3 deletions

View File

@ -424,3 +424,12 @@ SRWBackendVector::iterator find_best_backend(SRWBackendVector& backends,
* The following are implemented in rwsplit_tmp_table_multi.c
*/
void close_all_connections(mxs::SRWBackendList& 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

@ -29,7 +29,7 @@ using namespace maxscale;
*/
static std::string extract_error(GWBUF* buffer)
std::string extract_error(GWBUF* buffer)
{
std::string rval;

View File

@ -943,7 +943,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());
}
}