Fixed backend selection logic in get_dcb. If slave is not found write a warning to error log and fall through to master selection. If master has changed or previous master's state has changed, routing fails.
This commit is contained in:
@ -1790,13 +1790,13 @@ void protocol_archive_srv_command(
|
|||||||
}
|
}
|
||||||
|
|
||||||
s1 = &p->protocol_command;
|
s1 = &p->protocol_command;
|
||||||
|
#if defined(EXTRA_SS_DEBUG)
|
||||||
LOGIF(LT, (skygw_log_write(
|
LOGIF(LT, (skygw_log_write(
|
||||||
LOGFILE_TRACE,
|
LOGFILE_TRACE,
|
||||||
"Move command %s from fd %d to command history.",
|
"Move command %s from fd %d to command history.",
|
||||||
STRPACKETTYPE(s1->scom_cmd),
|
STRPACKETTYPE(s1->scom_cmd),
|
||||||
p->owner_dcb->fd)));
|
p->owner_dcb->fd)));
|
||||||
|
#endif
|
||||||
/** Copy to history list */
|
/** Copy to history list */
|
||||||
if ((h1 = p->protocol_cmd_history) == NULL)
|
if ((h1 = p->protocol_cmd_history) == NULL)
|
||||||
{
|
{
|
||||||
@ -1874,7 +1874,7 @@ void protocol_add_srv_command(
|
|||||||
STRPACKETTYPE(cmd),
|
STRPACKETTYPE(cmd),
|
||||||
p->owner_dcb->fd)));
|
p->owner_dcb->fd)));
|
||||||
|
|
||||||
#if defined(SS_DEBUG)
|
#if defined(EXTRA_SS_DEBUG)
|
||||||
c = &p->protocol_command;
|
c = &p->protocol_command;
|
||||||
|
|
||||||
while (c != NULL && c->scom_cmd != MYSQL_COM_UNDEFINED)
|
while (c != NULL && c->scom_cmd != MYSQL_COM_UNDEFINED)
|
||||||
|
@ -1177,38 +1177,15 @@ static bool get_dcb(
|
|||||||
"Warning : No slaves available "
|
"Warning : No slaves available "
|
||||||
"for the service %s.",
|
"for the service %s.",
|
||||||
rses->router->service->name)));
|
rses->router->service->name)));
|
||||||
}
|
}
|
||||||
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
btype = BE_MASTER;
|
LOGFILE_ERROR,
|
||||||
|
"Warning : Using master %s:%d.",
|
||||||
if (BREF_IS_IN_USE(master_bref))
|
master_bref->bref_backend->backend_server->name,
|
||||||
{
|
master_bref->bref_backend->backend_server->port)));
|
||||||
*p_dcb = master_bref->bref_dcb;
|
btype = BE_MASTER;
|
||||||
succp = true;
|
|
||||||
|
|
||||||
ss_dassert(master_bref->bref_dcb->state != DCB_STATE_ZOMBIE);
|
|
||||||
|
|
||||||
ss_dassert(
|
|
||||||
(master_bref->bref_backend &&
|
|
||||||
(master_bref->bref_backend->backend_server ==
|
|
||||||
master_bref->bref_backend->backend_server)) &&
|
|
||||||
smallest_nconn == -1);
|
|
||||||
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"Using master %s:%d instead.",
|
|
||||||
master_bref->bref_backend->backend_server->name,
|
|
||||||
master_bref->bref_backend->backend_server->port)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LOGIF(LE, (skygw_log_write_flush(
|
|
||||||
LOGFILE_ERROR,
|
|
||||||
"Error : No master is availabe either. "
|
|
||||||
"Unable to find backend server for "
|
|
||||||
"routing.")));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
/** Found slave, correct the status flag */
|
||||||
else if (rses->router->available_slaves == false)
|
else if (rses->router->available_slaves == false)
|
||||||
{
|
{
|
||||||
rses->router->available_slaves = true;
|
rses->router->available_slaves = true;
|
||||||
@ -1217,25 +1194,31 @@ static bool get_dcb(
|
|||||||
"At least one slave has become available for "
|
"At least one slave has become available for "
|
||||||
"the service %s.",
|
"the service %s.",
|
||||||
rses->router->service->name)));
|
rses->router->service->name)));
|
||||||
|
goto return_succp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btype == BE_MASTER)
|
if (btype == BE_MASTER)
|
||||||
{
|
{
|
||||||
for (i=0; i<rses->rses_nbackends; i++)
|
if (BREF_IS_IN_USE(master_bref) &&
|
||||||
{
|
SERVER_IS_MASTER(master_bref->bref_backend->backend_server))
|
||||||
BACKEND* b = backend_ref[i].bref_backend;
|
{
|
||||||
|
*p_dcb = master_bref->bref_dcb;
|
||||||
if (BREF_IS_IN_USE((&backend_ref[i])) &&
|
succp = true;
|
||||||
(master_bref->bref_backend &&
|
/** if bref is in use DCB should not be closed */
|
||||||
(b->backend_server ==
|
ss_dassert(master_bref->bref_dcb->state != DCB_STATE_ZOMBIE);
|
||||||
master_bref->bref_backend->backend_server)))
|
}
|
||||||
{
|
else
|
||||||
*p_dcb = backend_ref[i].bref_dcb;
|
{
|
||||||
succp = true;
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
goto return_succp;
|
LOGFILE_ERROR,
|
||||||
}
|
"Error : Server at %s:%d should be master but "
|
||||||
}
|
"is %s instead and can't be chosen to master.",
|
||||||
|
master_bref->bref_backend->backend_server->name,
|
||||||
|
master_bref->bref_backend->backend_server->port,
|
||||||
|
STRSRVSTATUS(master_bref->bref_backend->backend_server))));
|
||||||
|
succp = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return_succp:
|
return_succp:
|
||||||
@ -4138,16 +4121,18 @@ static void handleError (
|
|||||||
"Session will be closed.")));
|
"Session will be closed.")));
|
||||||
|
|
||||||
*succp = false;
|
*succp = false;
|
||||||
rses_end_locked_router_action(rses);
|
|
||||||
}
|
}
|
||||||
/**
|
else
|
||||||
* This is called in hope of getting replacement for
|
{
|
||||||
* failed slave(s).
|
/**
|
||||||
*/
|
* This is called in hope of getting replacement for
|
||||||
*succp = handle_error_new_connection(inst,
|
* failed slave(s).
|
||||||
rses,
|
*/
|
||||||
backend_dcb,
|
*succp = handle_error_new_connection(inst,
|
||||||
errmsgbuf);
|
rses,
|
||||||
|
backend_dcb,
|
||||||
|
errmsgbuf);
|
||||||
|
}
|
||||||
rses_end_locked_router_action(rses);
|
rses_end_locked_router_action(rses);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -4716,7 +4701,7 @@ static backend_ref_t* get_root_master_bref(
|
|||||||
LOGIF(LE, (skygw_log_write_flush(
|
LOGIF(LE, (skygw_log_write_flush(
|
||||||
LOGFILE_ERROR,
|
LOGFILE_ERROR,
|
||||||
"Error : Could not find master among the backend "
|
"Error : Could not find master among the backend "
|
||||||
"servers. Previous master state : %s",
|
"servers. Previous master's state : %s",
|
||||||
STRSRVSTATUS(BREFSRV(rses->rses_master_ref)))));
|
STRSRVSTATUS(BREFSRV(rses->rses_master_ref)))));
|
||||||
}
|
}
|
||||||
return candidate_bref;
|
return candidate_bref;
|
||||||
|
Reference in New Issue
Block a user