Added logging and som checks.
This commit is contained in:
@ -155,6 +155,8 @@ return_rc:
|
|||||||
/**
|
/**
|
||||||
* Remove a descriptor from the set of descriptors within the
|
* Remove a descriptor from the set of descriptors within the
|
||||||
* polling environment.
|
* polling environment.
|
||||||
|
* The state change command may fail because concurrent threads may call
|
||||||
|
* dcb_set_state simultaneously and the conflict is prevented in dcb_set_state.
|
||||||
*
|
*
|
||||||
* @param dcb The descriptor to remove
|
* @param dcb The descriptor to remove
|
||||||
* @return -1 on error or 0 on success
|
* @return -1 on error or 0 on success
|
||||||
@ -169,6 +171,10 @@ poll_remove_dcb(DCB *dcb)
|
|||||||
|
|
||||||
CHK_DCB(dcb);
|
CHK_DCB(dcb);
|
||||||
|
|
||||||
|
if (dcb->state != DCB_STATE_POLLING) {
|
||||||
|
goto return_rc;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set state to NOPOLLING and remove dcb from poll set.
|
* Set state to NOPOLLING and remove dcb from poll set.
|
||||||
*/
|
*/
|
||||||
@ -195,22 +201,6 @@ poll_remove_dcb(DCB *dcb)
|
|||||||
rc = 0;
|
rc = 0;
|
||||||
goto return_rc;
|
goto return_rc;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* State transition failed. This may be due some more serious error
|
|
||||||
* in how dcb is handled.
|
|
||||||
*/
|
|
||||||
else
|
|
||||||
{
|
|
||||||
skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"%lu [poll_remove_dcb] Unable to set state %s for dcb %p "
|
|
||||||
"in state %s. Removing from poll set failed.",
|
|
||||||
pthread_self(),
|
|
||||||
STRDCBSTATE(new_state),
|
|
||||||
STRDCBSTATE(old_state));
|
|
||||||
ss_dassert(false);
|
|
||||||
goto return_rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Set bit for each maxscale thread */
|
/** Set bit for each maxscale thread */
|
||||||
bitmask_copy(&dcb->memdata.bitmask, poll_bitmask());
|
bitmask_copy(&dcb->memdata.bitmask, poll_bitmask());
|
||||||
@ -315,10 +305,9 @@ poll_waitevents(void *arg)
|
|||||||
if (dcb_fake_write_ev[dcb->fd] != 0) {
|
if (dcb_fake_write_ev[dcb->fd] != 0) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu %d [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"Added fake events %d to ev %d.",
|
"Added fake events %d to ev %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
thread_id,
|
|
||||||
dcb_fake_write_ev[dcb->fd],
|
dcb_fake_write_ev[dcb->fd],
|
||||||
ev);
|
ev);
|
||||||
ev |= dcb_fake_write_ev[dcb->fd];
|
ev |= dcb_fake_write_ev[dcb->fd];
|
||||||
@ -333,9 +322,8 @@ poll_waitevents(void *arg)
|
|||||||
|
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu %d [poll_waitevents] event %d dcb %p",
|
"%lu [poll_waitevents] event %d dcb %p",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
thread_id,
|
|
||||||
ev,
|
ev,
|
||||||
dcb);
|
dcb);
|
||||||
|
|
||||||
@ -347,10 +335,9 @@ poll_waitevents(void *arg)
|
|||||||
eno = dcb_fake_write_errno[dcb->fd];
|
eno = dcb_fake_write_errno[dcb->fd];
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu %d [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"Added fake errno %d. %s",
|
"Added fake errno %d. %s",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
thread_id,
|
|
||||||
eno,
|
eno,
|
||||||
strerror(eno));
|
strerror(eno));
|
||||||
}
|
}
|
||||||
@ -359,10 +346,9 @@ poll_waitevents(void *arg)
|
|||||||
if (eno != 0) {
|
if (eno != 0) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu %d [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"EPOLLERR due %d, %s.",
|
"EPOLLERR due %d, %s.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
thread_id,
|
|
||||||
eno,
|
eno,
|
||||||
strerror(eno));
|
strerror(eno));
|
||||||
}
|
}
|
||||||
@ -404,10 +390,9 @@ poll_waitevents(void *arg)
|
|||||||
{
|
{
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu %d [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"Accept in fd %d",
|
"Accept in fd %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
thread_id,
|
|
||||||
dcb->fd);
|
dcb->fd);
|
||||||
atomic_add(&pollStats.n_accept, 1);
|
atomic_add(&pollStats.n_accept, 1);
|
||||||
dcb->func.accept(dcb);
|
dcb->func.accept(dcb);
|
||||||
@ -416,10 +401,9 @@ poll_waitevents(void *arg)
|
|||||||
{
|
{
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu %d [poll_waitevents] "
|
"%lu [poll_waitevents] "
|
||||||
"Read in dcb %p fd %d",
|
"Read in dcb %p fd %d",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
thread_id,
|
|
||||||
dcb,
|
dcb,
|
||||||
dcb->fd);
|
dcb->fd);
|
||||||
atomic_add(&pollStats.n_read, 1);
|
atomic_add(&pollStats.n_read, 1);
|
||||||
|
@ -70,8 +70,8 @@ session_alloc(SERVICE *service, DCB *client)
|
|||||||
errno = 0;
|
errno = 0;
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"%lu [session_alloc] Allocating memory for session "
|
"%lu [session_alloc] FAiled to allocate memory for session "
|
||||||
"object failed. Errno %d, %s.",
|
"object due error %d, %s.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
eno,
|
eno,
|
||||||
strerror(eno));
|
strerror(eno));
|
||||||
@ -126,8 +126,8 @@ session_alloc(SERVICE *service, DCB *client)
|
|||||||
client->session = NULL;
|
client->session = NULL;
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"%lu [session_alloc] Creating router client session "
|
"%lu [session_alloc] Failed to create router "
|
||||||
"failed. Freeing session.",
|
"client session. Freeing allocated resources.",
|
||||||
pthread_self());
|
pthread_self());
|
||||||
free(session);
|
free(session);
|
||||||
session = NULL;
|
session = NULL;
|
||||||
|
@ -304,9 +304,10 @@ int i;
|
|||||||
if(inst->servers[i]) {
|
if(inst->servers[i]) {
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_TRACE,
|
||||||
"Examine server in port %d with %d connections. "
|
"%lu [newSession] Examine server in port %d with "
|
||||||
"Status is %d, "
|
"%d connections. Status is %d, "
|
||||||
"inst->bitvalue is %d",
|
"inst->bitvalue is %d",
|
||||||
|
pthread_self(),
|
||||||
inst->servers[i]->server->port,
|
inst->servers[i]->server->port,
|
||||||
inst->servers[i]->current_connection_count,
|
inst->servers[i]->current_connection_count,
|
||||||
inst->servers[i]->server->status,
|
inst->servers[i]->server->status,
|
||||||
@ -348,8 +349,9 @@ int i;
|
|||||||
if (!candidate) {
|
if (!candidate) {
|
||||||
skygw_log_write_flush(
|
skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"%lu [newSession] Couldn't find eligible candidate "
|
"%lu [newSession] Failed to create new routing session. "
|
||||||
"server. Exiting.",
|
"Couldn't find eligible candidate server. Freeing "
|
||||||
|
"allocated resources.",
|
||||||
pthread_self());
|
pthread_self());
|
||||||
free(client_ses);
|
free(client_ses);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -380,8 +382,9 @@ int i;
|
|||||||
atomic_add(&candidate->current_connection_count, -1);
|
atomic_add(&candidate->current_connection_count, -1);
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"%lu [newSession] Failed to establish connection to "
|
"%lu [newSession] Failed to create new routing session. "
|
||||||
"server in port %d. Exiting.",
|
"Couldn't establish connection to candidate server "
|
||||||
|
"listening to port %d. Freeing allocated resources.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
candidate->server->port);
|
candidate->server->port);
|
||||||
free(client_ses);
|
free(client_ses);
|
||||||
@ -493,38 +496,38 @@ bool succp = false;
|
|||||||
static int
|
static int
|
||||||
routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
|
routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
|
||||||
{
|
{
|
||||||
ROUTER_INSTANCE *inst = (ROUTER_INSTANCE *)instance;
|
ROUTER_INSTANCE *inst = (ROUTER_INSTANCE *)instance;
|
||||||
ROUTER_CLIENT_SES *session = (ROUTER_CLIENT_SES *)router_session;
|
ROUTER_CLIENT_SES *rsession = (ROUTER_CLIENT_SES *)router_session;
|
||||||
uint8_t *payload = GWBUF_DATA(queue);
|
uint8_t *payload = GWBUF_DATA(queue);
|
||||||
int mysql_command;
|
int mysql_command;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
inst->stats.n_queries++;
|
inst->stats.n_queries++;
|
||||||
|
|
||||||
mysql_command = MYSQL_GET_COMMAND(payload);
|
mysql_command = MYSQL_GET_COMMAND(payload);
|
||||||
|
|
||||||
switch(mysql_command) {
|
switch(mysql_command) {
|
||||||
case MYSQL_COM_CHANGE_USER:
|
case MYSQL_COM_CHANGE_USER:
|
||||||
rc = session->backend_dcb->func.auth(
|
rc = rsession->backend_dcb->func.auth(
|
||||||
session->backend_dcb,
|
rsession->backend_dcb,
|
||||||
NULL,
|
NULL,
|
||||||
session->backend_dcb->session,
|
rsession->backend_dcb->session,
|
||||||
queue);
|
queue);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
rc = session->backend_dcb->func.write(
|
rc = rsession->backend_dcb->func.write(
|
||||||
session->backend_dcb,
|
rsession->backend_dcb,
|
||||||
queue);
|
queue);
|
||||||
}
|
}
|
||||||
CHK_PROTOCOL(((MySQLProtocol*)session->backend_dcb->protocol));
|
|
||||||
|
CHK_PROTOCOL(((MySQLProtocol*)rsession->backend_dcb->protocol));
|
||||||
skygw_log_write(
|
skygw_log_write(
|
||||||
LOGFILE_DEBUG,
|
LOGFILE_DEBUG,
|
||||||
"%lu [readconnroute:routeQuery] Routed command %d to dcb %p "
|
"%lu [readconnroute:routeQuery] Routed command %d to dcb %p "
|
||||||
"with return value %d.",
|
"with return value %d.",
|
||||||
pthread_self(),
|
pthread_self(),
|
||||||
mysql_command,
|
mysql_command,
|
||||||
session->backend_dcb,
|
rsession->backend_dcb,
|
||||||
rc);
|
rc);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Reference in New Issue
Block a user