Add more error logging to DCB handling
If an illegal DCB close is done with a backend DCB, it will log the server where it was connected. This allows us to know whether the DCB was connected to a master or a slave. Added more debug assertions to readwritesplit code. The DCBs should never enter the DCB_STATE_DISCONNECTED. Removed useless debug log messages. The messages usually just flood the logs with no use to the developers.
This commit is contained in:
@ -1747,6 +1747,38 @@ dcb_grab_writeq(DCB *dcb, bool first_time)
|
|||||||
return local_writeq;
|
return local_writeq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void log_illegal_dcb(DCB *dcb)
|
||||||
|
{
|
||||||
|
const char *connected_to;
|
||||||
|
|
||||||
|
switch (dcb->dcb_role)
|
||||||
|
{
|
||||||
|
case DCB_ROLE_BACKEND_HANDLER:
|
||||||
|
connected_to = dcb->server->unique_name;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DCB_ROLE_CLIENT_HANDLER:
|
||||||
|
connected_to = dcb->remote;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DCB_ROLE_INTERNAL:
|
||||||
|
connected_to = "Internal DCB";
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DCB_ROLE_SERVICE_LISTENER:
|
||||||
|
connected_to = dcb->service->name;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
connected_to = "Illegal DCB role";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
MXS_ERROR("[dcb_close] Error : Removing DCB %p but it is in state %s "
|
||||||
|
"which is not legal for a call to dcb_close. The DCB is connected to: %s",
|
||||||
|
dcb, STRDCBSTATE(dcb->state), connected_to);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes dcb from poll set, and adds it to zombies list. As a consequence,
|
* Removes dcb from poll set, and adds it to zombies list. As a consequence,
|
||||||
* dcb first moves to DCB_STATE_NOPOLLING, and then to DCB_STATE_ZOMBIE state.
|
* dcb first moves to DCB_STATE_NOPOLLING, and then to DCB_STATE_ZOMBIE state.
|
||||||
@ -1766,11 +1798,7 @@ dcb_close(DCB *dcb)
|
|||||||
if (DCB_STATE_UNDEFINED == dcb->state
|
if (DCB_STATE_UNDEFINED == dcb->state
|
||||||
|| DCB_STATE_DISCONNECTED == dcb->state)
|
|| DCB_STATE_DISCONNECTED == dcb->state)
|
||||||
{
|
{
|
||||||
MXS_ERROR("%lu [dcb_close] Error : Removing DCB %p but was in state %s "
|
log_illegal_dcb(dcb);
|
||||||
"which is not legal for a call to dcb_close. ",
|
|
||||||
pthread_self(),
|
|
||||||
dcb,
|
|
||||||
STRDCBSTATE(dcb->state));
|
|
||||||
raise(SIGABRT);
|
raise(SIGABRT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,9 +1032,6 @@ gw_read_and_write(DCB *dcb, MYSQL_session local_session)
|
|||||||
{
|
{
|
||||||
GWBUF* errbuf;
|
GWBUF* errbuf;
|
||||||
bool succp;
|
bool succp;
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
MXS_ERROR("Backend read error handling #2.");
|
|
||||||
#endif
|
|
||||||
errbuf = mysql_create_custom_error(1,
|
errbuf = mysql_create_custom_error(1,
|
||||||
0,
|
0,
|
||||||
"Read from backend failed");
|
"Read from backend failed");
|
||||||
@ -1554,12 +1551,6 @@ static int gw_backend_hangup(DCB *dcb)
|
|||||||
/* dcb_close(dcb); */
|
/* dcb_close(dcb); */
|
||||||
goto retblock;
|
goto retblock;
|
||||||
}
|
}
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
if (ses_state != SESSION_STATE_STOPPING)
|
|
||||||
{
|
|
||||||
MXS_ERROR("Backend hangup error handling.");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
router->handleError(router_instance,
|
router->handleError(router_instance,
|
||||||
rsession,
|
rsession,
|
||||||
@ -1572,9 +1563,6 @@ static int gw_backend_hangup(DCB *dcb)
|
|||||||
/** There are no required backends available, close session. */
|
/** There are no required backends available, close session. */
|
||||||
if (!succp)
|
if (!succp)
|
||||||
{
|
{
|
||||||
#if defined(SS_DEBUG)
|
|
||||||
MXS_ERROR("Backend hangup -> closing session.");
|
|
||||||
#endif
|
|
||||||
spinlock_acquire(&session->ses_lock);
|
spinlock_acquire(&session->ses_lock);
|
||||||
session->state = SESSION_STATE_STOPPING;
|
session->state = SESSION_STATE_STOPPING;
|
||||||
spinlock_release(&session->ses_lock);
|
spinlock_release(&session->ses_lock);
|
||||||
|
@ -1096,7 +1096,8 @@ static bool get_dcb(DCB **p_dcb, ROUTER_CLIENT_SES *rses, backend_type_t btype,
|
|||||||
{
|
{
|
||||||
*p_dcb = backend_ref[i].bref_dcb;
|
*p_dcb = backend_ref[i].bref_dcb;
|
||||||
succp = true;
|
succp = true;
|
||||||
ss_dassert(backend_ref[i].bref_dcb->state != DCB_STATE_ZOMBIE);
|
ss_dassert(backend_ref[i].bref_dcb->state != DCB_STATE_ZOMBIE ||
|
||||||
|
backend_ref[i].bref_dcb->state != DCB_STATE_DISCONNECTED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1228,7 +1229,8 @@ static bool get_dcb(DCB **p_dcb, ROUTER_CLIENT_SES *rses, backend_type_t btype,
|
|||||||
*p_dcb = master_bref->bref_dcb;
|
*p_dcb = master_bref->bref_dcb;
|
||||||
succp = true;
|
succp = true;
|
||||||
/** if bref is in use DCB should not be closed */
|
/** if bref is in use DCB should not be closed */
|
||||||
ss_dassert(master_bref->bref_dcb->state != DCB_STATE_ZOMBIE);
|
ss_dassert(master_bref->bref_dcb->state != DCB_STATE_ZOMBIE ||
|
||||||
|
master_bref->bref_dcb->state != DCB_STATE_DISCONNECTED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user