Dump queue contents on unexpectedly NULL buffer
When the query queue does not contain a complete packet (i.e. modutil_get_next_MySQL_packet return NULL), an informative dump of how many bytes and what is stored is logged.
This commit is contained in:
@ -403,10 +403,11 @@ extern void dprintAllBuffers(void *pdcb);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Debug function for dumping buffer contents to INFO log
|
||||
* Debug function for dumping buffer contents to log
|
||||
*
|
||||
* @param buffer Buffer to dump
|
||||
* @param log_level Log priority where the message is written
|
||||
*/
|
||||
void gwbuf_hexdump(GWBUF* buffer);
|
||||
void gwbuf_hexdump(GWBUF* buffer, int log_level);
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -892,7 +892,7 @@ static std::string dump_one_buffer(GWBUF* buffer)
|
||||
return rval;
|
||||
}
|
||||
|
||||
void gwbuf_hexdump(GWBUF* buffer)
|
||||
void gwbuf_hexdump(GWBUF* buffer, int log_level)
|
||||
{
|
||||
std::stringstream ss;
|
||||
|
||||
@ -910,5 +910,5 @@ void gwbuf_hexdump(GWBUF* buffer)
|
||||
n = 1024;
|
||||
}
|
||||
|
||||
MXS_INFO("%.*s", n, ss.str().c_str());
|
||||
MXS_LOG_MESSAGE(log_level, "%.*s", n, ss.str().c_str());
|
||||
}
|
||||
|
@ -473,6 +473,14 @@ static bool route_stored_query(RWSplitSession *rses)
|
||||
query_queue = gwbuf_make_contiguous(query_queue);
|
||||
ss_dassert(query_queue);
|
||||
|
||||
if (query_queue == NULL)
|
||||
{
|
||||
MXS_ALERT("Queued query unexpectedly empty. Bytes queued: %d Hexdump: ",
|
||||
gwbuf_length(rses->query_queue));
|
||||
gwbuf_hexdump(rses->query_queue, LOG_ALERT);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Store the query queue locally for the duration of the routeQuery call.
|
||||
* This prevents recursive calls into this function. */
|
||||
GWBUF *temp_storage = rses->query_queue;
|
||||
|
Reference in New Issue
Block a user