Merge branch '2.0' into develop
This commit is contained in:
@ -1127,10 +1127,6 @@ monitorMain(void *arg)
|
||||
{
|
||||
dcb_hangup_foreach(ptr->server);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (mon_status_changed(ptr))
|
||||
@ -1225,6 +1221,8 @@ monitorMain(void *arg)
|
||||
ptr = mon->databases;
|
||||
while (ptr)
|
||||
{
|
||||
MYSQL_SERVER_INFO *serv_info = hashtable_fetch(handle->server_info, ptr->server->unique_name);
|
||||
ss_dassert(serv_info);
|
||||
if (!SERVER_IN_MAINT(ptr->server))
|
||||
{
|
||||
/** If "detect_stale_master" option is On, let's use the previous master.
|
||||
@ -1287,6 +1285,10 @@ monitorMain(void *arg)
|
||||
{
|
||||
ptr->pending_status |= SERVER_SLAVE;
|
||||
}
|
||||
else if (root_master == NULL && serv_info->slave_configured)
|
||||
{
|
||||
ptr->pending_status |= SERVER_SLAVE;
|
||||
}
|
||||
}
|
||||
|
||||
ptr->server->status = ptr->pending_status;
|
||||
|
||||
@ -1185,48 +1185,38 @@ static int gw_write_backend_event(DCB *dcb)
|
||||
*/
|
||||
if (dcb->state != DCB_STATE_POLLING)
|
||||
{
|
||||
uint8_t* data;
|
||||
uint8_t* data = NULL;
|
||||
bool com_quit = false;
|
||||
|
||||
if (dcb->writeq != NULL)
|
||||
spinlock_acquire(&dcb->writeqlock);
|
||||
if (dcb->writeq)
|
||||
{
|
||||
data = (uint8_t *) GWBUF_DATA(dcb->writeq);
|
||||
com_quit = MYSQL_IS_COM_QUIT(data);
|
||||
rc = 0;
|
||||
}
|
||||
spinlock_release(&dcb->writeqlock);
|
||||
|
||||
if (dcb->session->client_dcb == NULL)
|
||||
{
|
||||
rc = 0;
|
||||
}
|
||||
else if (!(MYSQL_IS_COM_QUIT(data)))
|
||||
{
|
||||
/*< vraa : errorHandle */
|
||||
mysql_send_custom_error(dcb->session->client_dcb,
|
||||
1,
|
||||
0,
|
||||
"Writing to backend failed due invalid Maxscale "
|
||||
"state.");
|
||||
MXS_DEBUG("%lu [gw_write_backend_event] Write to backend "
|
||||
"dcb %p fd %d "
|
||||
"failed due invalid state %s.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
dcb->fd,
|
||||
STRDCBSTATE(dcb->state));
|
||||
|
||||
MXS_ERROR("Attempt to write buffered data to backend "
|
||||
"failed "
|
||||
"due internal inconsistent state.");
|
||||
if (data && !com_quit)
|
||||
{
|
||||
mysql_send_custom_error(dcb->session->client_dcb, 1, 0,
|
||||
"Writing to backend failed due invalid Maxscale state.");
|
||||
MXS_DEBUG("%lu [gw_write_backend_event] Write to backend "
|
||||
"dcb %p fd %d failed due invalid state %s.",
|
||||
pthread_self(), dcb, dcb->fd, STRDCBSTATE(dcb->state));
|
||||
|
||||
rc = 0;
|
||||
}
|
||||
MXS_ERROR("Attempt to write buffered data to backend "
|
||||
"failed due internal inconsistent state.");
|
||||
}
|
||||
else
|
||||
{
|
||||
MXS_DEBUG("%lu [gw_write_backend_event] Dcb %p in state %s "
|
||||
"but there's nothing to write either.",
|
||||
pthread_self(),
|
||||
dcb,
|
||||
STRDCBSTATE(dcb->state));
|
||||
"but there's nothing to write either.",
|
||||
pthread_self(), dcb, STRDCBSTATE(dcb->state));
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
goto return_rc;
|
||||
}
|
||||
|
||||
@ -2031,22 +2021,17 @@ static GWBUF* process_response_data(DCB* dcb,
|
||||
outbuf = gwbuf_append(outbuf, readbuf);
|
||||
readbuf = NULL;
|
||||
}
|
||||
/**
|
||||
* Packet was read. There should be more since bytes were
|
||||
* left over.
|
||||
* Move the next packet to its own buffer and add that next
|
||||
* to the prev packet's buffer.
|
||||
*/
|
||||
else /*< nbytes_left < nbytes_to_process */
|
||||
/**
|
||||
* Buffer contains more data than we need. Split the complete packet and
|
||||
* the extra data into two separate buffers.
|
||||
*/
|
||||
else
|
||||
{
|
||||
ss_dassert(nbytes_left >= 0);
|
||||
nbytes_to_process -= nbytes_left;
|
||||
|
||||
/** Move the prefix of the buffer to outbuf from redbuf */
|
||||
outbuf = gwbuf_append(outbuf,
|
||||
gwbuf_clone_portion(readbuf, 0, (size_t) nbytes_left));
|
||||
readbuf = gwbuf_consume(readbuf, (size_t) nbytes_left);
|
||||
ss_dassert(nbytes_left < nbytes_to_process);
|
||||
ss_dassert(nbytes_left > 0);
|
||||
ss_dassert(npackets_left > 0);
|
||||
outbuf = gwbuf_append(outbuf, gwbuf_split(&readbuf, nbytes_left));
|
||||
nbytes_to_process -= nbytes_left;
|
||||
npackets_left -= 1;
|
||||
nbytes_left = 0;
|
||||
}
|
||||
|
||||
@ -651,7 +651,7 @@ static void closeSession(ROUTER *instance, void *router_session)
|
||||
}
|
||||
#endif
|
||||
/** Clean operation counter in bref and in SERVER */
|
||||
while (BREF_IS_WAITING_RESULT(bref))
|
||||
if (BREF_IS_WAITING_RESULT(bref))
|
||||
{
|
||||
bref_clear_state(bref, BREF_WAITING_RESULT);
|
||||
}
|
||||
@ -664,6 +664,10 @@ static void closeSession(ROUTER *instance, void *router_session)
|
||||
/** decrease server current connection counters */
|
||||
atomic_add(&bref->bref_backend->backend_conn_count, -1);
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dassert(!BREF_IS_WAITING_RESULT(bref));
|
||||
}
|
||||
}
|
||||
/** Unlock */
|
||||
rses_end_locked_router_action(router_cli_ses);
|
||||
@ -1121,6 +1125,10 @@ static void handleError(ROUTER *instance, void *router_session,
|
||||
if (bref != NULL)
|
||||
{
|
||||
CHK_BACKEND_REF(bref);
|
||||
if (BREF_IS_WAITING_RESULT(bref))
|
||||
{
|
||||
bref_clear_state(bref, BREF_WAITING_RESULT);
|
||||
}
|
||||
bref_clear_state(bref, BREF_IN_USE);
|
||||
bref_set_state(bref, BREF_CLOSED);
|
||||
}
|
||||
@ -1281,7 +1289,6 @@ void rses_end_locked_router_action(ROUTER_CLIENT_SES *rses)
|
||||
* @param bref The backend reference to be modified
|
||||
* @param state A bit string where the 1 bits indicate bits that should
|
||||
* be turned off in the bref state.
|
||||
*
|
||||
*/
|
||||
void bref_clear_state(backend_ref_t *bref, bref_state_t state)
|
||||
{
|
||||
@ -1290,11 +1297,8 @@ void bref_clear_state(backend_ref_t *bref, bref_state_t state)
|
||||
MXS_ERROR("[%s] Error: NULL parameter.", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
if (state != BREF_WAITING_RESULT)
|
||||
{
|
||||
bref->bref_state &= ~state;
|
||||
}
|
||||
else
|
||||
|
||||
if ((state & BREF_WAITING_RESULT) && (bref->bref_state & BREF_WAITING_RESULT))
|
||||
{
|
||||
int prev1;
|
||||
int prev2;
|
||||
@ -1319,6 +1323,8 @@ void bref_clear_state(backend_ref_t *bref, bref_state_t state)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bref->bref_state &= ~state;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1332,7 +1338,6 @@ void bref_clear_state(backend_ref_t *bref, bref_state_t state)
|
||||
* @param bref The backend reference to be modified
|
||||
* @param state A bit string where the 1 bits indicate bits that should
|
||||
* be turned on in the bref state.
|
||||
*
|
||||
*/
|
||||
void bref_set_state(backend_ref_t *bref, bref_state_t state)
|
||||
{
|
||||
@ -1341,11 +1346,8 @@ void bref_set_state(backend_ref_t *bref, bref_state_t state)
|
||||
MXS_ERROR("[%s] Error: NULL parameter.", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
if (state != BREF_WAITING_RESULT)
|
||||
{
|
||||
bref->bref_state |= state;
|
||||
}
|
||||
else
|
||||
|
||||
if ((state & BREF_WAITING_RESULT) && (bref->bref_state & BREF_WAITING_RESULT) == 0)
|
||||
{
|
||||
int prev1;
|
||||
int prev2;
|
||||
@ -1371,6 +1373,8 @@ void bref_set_state(backend_ref_t *bref, bref_state_t state)
|
||||
bref->bref_backend->backend_server->port);
|
||||
}
|
||||
}
|
||||
|
||||
bref->bref_state |= state;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1684,6 +1688,10 @@ static void handle_error_reply_client(SESSION *ses, ROUTER_CLIENT_SES *rses,
|
||||
CHK_BACKEND_REF(bref);
|
||||
bref_clear_state(bref, BREF_IN_USE);
|
||||
bref_set_state(bref, BREF_CLOSED);
|
||||
if (BREF_IS_WAITING_RESULT(bref))
|
||||
{
|
||||
bref_clear_state(bref, BREF_WAITING_RESULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (sesstate == SESSION_STATE_ROUTER_READY)
|
||||
|
||||
Reference in New Issue
Block a user