Fixed queries being routed when the session is already closing.
This commit is contained in:
@ -197,6 +197,7 @@ GWBUF *rval;
|
||||
rval->gwbuf_info = buf->gwbuf_info;
|
||||
rval->gwbuf_bufobj = buf->gwbuf_bufobj;
|
||||
rval->tail = rval;
|
||||
rval->next = NULL;
|
||||
CHK_GWBUF(rval);
|
||||
return rval;
|
||||
}
|
||||
|
@ -1080,7 +1080,7 @@ gw_backend_hangup(DCB *dcb)
|
||||
len = sizeof(error);
|
||||
if (getsockopt(dcb->fd, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&len) == 0)
|
||||
{
|
||||
if (error != 0)
|
||||
if (error != 0 && ses_state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
strerror_r(error, buf, 100);
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
@ -1094,9 +1094,12 @@ gw_backend_hangup(DCB *dcb)
|
||||
goto retblock;
|
||||
}
|
||||
#if defined(SS_DEBUG)
|
||||
if(ses_state != SESSION_STATE_STOPPING)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Backend hangup error handling.")));
|
||||
}
|
||||
#endif
|
||||
|
||||
router->handleError(router_instance,
|
||||
|
@ -1092,6 +1092,7 @@ int gw_read_client_event(
|
||||
case MYSQL_IDLE:
|
||||
{
|
||||
uint8_t* payload = NULL;
|
||||
session_state_t ses_state;
|
||||
|
||||
session = dcb->session;
|
||||
ss_dassert(session!= NULL);
|
||||
@ -1100,10 +1101,15 @@ int gw_read_client_event(
|
||||
{
|
||||
CHK_SESSION(session);
|
||||
}
|
||||
spinlock_acquire(&session->ses_lock);
|
||||
ses_state = session->state;
|
||||
spinlock_release(&session->ses_lock);
|
||||
/* Now, we are assuming in the first buffer there is
|
||||
* the information form mysql command */
|
||||
payload = GWBUF_DATA(read_buffer);
|
||||
|
||||
if(ses_state == SESSION_STATE_ROUTER_READY)
|
||||
{
|
||||
/** Route COM_QUIT to backend */
|
||||
if (MYSQL_IS_COM_QUIT(payload))
|
||||
{
|
||||
@ -1187,6 +1193,14 @@ int gw_read_client_event(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
skygw_log_write_flush(LT,"Session received a query in state %s",
|
||||
STRSESSIONSTATE(ses_state));
|
||||
while((read_buffer = GWBUF_CONSUME_ALL(read_buffer)) != NULL);
|
||||
goto return_rc;
|
||||
}
|
||||
goto return_rc;
|
||||
} /* MYSQL_IDLE */
|
||||
break;
|
||||
|
@ -723,16 +723,10 @@ routeQuery(ROUTER *instance, void *router_session, GWBUF *queue)
|
||||
SERVER_IS_DOWN(router_cli_ses->backend->server))
|
||||
{
|
||||
LOGIF(LT, (skygw_log_write(
|
||||
LOGFILE_TRACE,
|
||||
LOGFILE_TRACE|LOGFILE_ERROR,
|
||||
"Error : Failed to route MySQL command %d to backend "
|
||||
"server.",
|
||||
mysql_command)));
|
||||
skygw_log_write(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Failed to route MySQL command %d to backend "
|
||||
"server %s.",
|
||||
mysql_command,
|
||||
router_cli_ses->backend->server->unique_name);
|
||||
"server.%s",
|
||||
mysql_command,rses_is_closed ? " Session is closed." : "")));
|
||||
rc = 0;
|
||||
goto return_rc;
|
||||
|
||||
|
@ -3915,7 +3915,7 @@ static GWBUF* sescmd_cursor_clone_querybuf(
|
||||
}
|
||||
ss_dassert(scur->scmd_cur_cmd != NULL);
|
||||
|
||||
buf = gwbuf_clone(scur->scmd_cur_cmd->my_sescmd_buf);
|
||||
buf = gwbuf_clone_all(scur->scmd_cur_cmd->my_sescmd_buf);
|
||||
|
||||
CHK_GWBUF(buf);
|
||||
return buf;
|
||||
|
Reference in New Issue
Block a user