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:
Markus Makela
2016-11-05 11:28:18 +02:00
parent 87e94f6bc6
commit c30d0dfc9d
3 changed files with 37 additions and 19 deletions

View File

@ -1747,6 +1747,38 @@ dcb_grab_writeq(DCB *dcb, bool first_time)
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,
* 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
|| DCB_STATE_DISCONNECTED == dcb->state)
{
MXS_ERROR("%lu [dcb_close] Error : Removing DCB %p but was in state %s "
"which is not legal for a call to dcb_close. ",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state));
log_illegal_dcb(dcb);
raise(SIGABRT);
}

View File

@ -1032,9 +1032,6 @@ gw_read_and_write(DCB *dcb, MYSQL_session local_session)
{
GWBUF* errbuf;
bool succp;
#if defined(SS_DEBUG)
MXS_ERROR("Backend read error handling #2.");
#endif
errbuf = mysql_create_custom_error(1,
0,
"Read from backend failed");
@ -1554,12 +1551,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,
@ -1572,9 +1563,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);

View File

@ -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;
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;
}
}
@ -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;
succp = true;
/** 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
{