Log more precise DCB write error messages
The DCB error messages now log the type of the DCB and the remote address in addition to the system error message. The file descriptor and memory address are no longer printed in the error message as they are not useful to the end user. The fd and address are now logged at debug level with a more verbose error message.
This commit is contained in:
parent
53f01106aa
commit
cd11971d5d
@ -2412,55 +2412,6 @@ gw_write(DCB *dcb, GWBUF *writeq, bool *stop_writing)
|
||||
}
|
||||
#endif /* FAKE_CODE */
|
||||
|
||||
#if defined(SS_DEBUG_MYSQL)
|
||||
{
|
||||
size_t len;
|
||||
uint8_t* packet = (uint8_t *)buf;
|
||||
char* str;
|
||||
|
||||
/** Print only MySQL packets */
|
||||
if (written > 5)
|
||||
{
|
||||
str = (char *)&packet[5];
|
||||
len = packet[0];
|
||||
len += 256 * packet[1];
|
||||
len += 256 * 256 * packet[2];
|
||||
|
||||
if (strncmp(str, "insert", 6) == 0 ||
|
||||
strncmp(str, "create", 6) == 0 ||
|
||||
strncmp(str, "drop", 4) == 0)
|
||||
{
|
||||
ss_dassert((dcb->dcb_server_status & (SERVER_RUNNING | SERVER_MASTER | SERVER_SLAVE)) ==
|
||||
(SERVER_RUNNING | SERVER_MASTER));
|
||||
}
|
||||
|
||||
if (strncmp(str, "set autocommit", 14) == 0 && nbytes > 17)
|
||||
{
|
||||
char* s = (char *)MXS_CALLOC(1, nbytes + 1);
|
||||
MXS_ABORT_IF_NULL(s);
|
||||
|
||||
if (nbytes - 5 > len)
|
||||
{
|
||||
size_t len2 = packet[4 + len];
|
||||
len2 += 256 * packet[4 + len + 1];
|
||||
len2 += 256 * 256 * packet[4 + len + 2];
|
||||
|
||||
char* str2 = (char *)&packet[4 + len + 5];
|
||||
snprintf(s, 5 + len + len2, "long %s %s", (char *)str, (char *)str2);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(s, len, "%s", (char *)str);
|
||||
}
|
||||
MXS_INFO("%lu [gw_write] Wrote %d bytes : %s ",
|
||||
pthread_self(),
|
||||
w,
|
||||
s);
|
||||
MXS_FREE(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
saved_errno = errno;
|
||||
errno = 0;
|
||||
|
||||
@ -2477,13 +2428,13 @@ gw_write(DCB *dcb, GWBUF *writeq, bool *stop_writing)
|
||||
#endif
|
||||
{
|
||||
char errbuf[STRERROR_BUFLEN];
|
||||
MXS_ERROR("Write to dcb %p "
|
||||
"in state %s fd %d failed due errno %d, %s",
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state),
|
||||
dcb->fd,
|
||||
saved_errno,
|
||||
strerror_r(saved_errno, errbuf, sizeof(errbuf)));
|
||||
MXS_ERROR("Write to %s %s in state %s failed due errno %d, %s",
|
||||
DCB_STRTYPE(dcb), dcb->remote, STRDCBSTATE(dcb->state),
|
||||
saved_errno, strerror_r(saved_errno, errbuf, sizeof(errbuf)));
|
||||
MXS_DEBUG("Write to %s %s in state %s failed due errno %d, %s (at %p, fd %d)",
|
||||
DCB_STRTYPE(dcb), dcb->remote, STRDCBSTATE(dcb->state),
|
||||
saved_errno, strerror_r(saved_errno, errbuf, sizeof(errbuf)),
|
||||
dcb, dcb->fd);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -156,6 +156,11 @@ typedef enum
|
||||
DCB_ROLE_INTERNAL /*< Internal DCB not connected to the outside */
|
||||
} dcb_role_t;
|
||||
|
||||
#define DCB_STRTYPE(dcb) (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER ? "Client DCB" : \
|
||||
dcb->dcb_role == DCB_ROLE_BACKEND_HANDLER ? "Backend DCB" : \
|
||||
dcb->dcb_role == DCB_ROLE_SERVICE_LISTENER ? "Listener DCB" : \
|
||||
dcb->dcb_role == DCB_ROLE_INTERNAL ? "Internal DCB" : "Unknown DCB")
|
||||
|
||||
/**
|
||||
* Callback reasons for the DCB callback mechanism.
|
||||
*/
|
||||
|
@ -1549,12 +1549,6 @@ static int gw_backend_hangup(DCB *dcb)
|
||||
/* dcb_close(dcb); */
|
||||
goto retblock;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
if (ses_state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
MXS_ERROR("Backend hangup error handling.");
|
||||
}
|
||||
#endif
|
||||
|
||||
router->handleError(router_instance,
|
||||
rsession,
|
||||
@ -1567,9 +1561,6 @@ static int gw_backend_hangup(DCB *dcb)
|
||||
/** There are no required backends available, close session. */
|
||||
if (!succp)
|
||||
{
|
||||
#if defined(SS_DEBUG)
|
||||
MXS_ERROR("Backend hangup -> closing session.");
|
||||
#endif
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
session->state = SESSION_STATE_STOPPING;
|
||||
spinlock_release(&session->ses_lock);
|
||||
|
Loading…
x
Reference in New Issue
Block a user