Fix to MXS-323: Routers properly handle client DCB errors

All routers now detect if a client DCB is passed to handleError and
take the appropriate action.
This commit is contained in:
Markus Makela
2015-12-02 18:01:14 +02:00
parent 93f10fdb7b
commit d6afe70c6f
2 changed files with 58 additions and 50 deletions

View File

@ -4001,7 +4001,7 @@ return_succp:
/**
* Error Handler routine to resolve _backend_ failures. If it succeeds then there
* are enough operative backends available and connected. Otherwise it fails,
* are enough operative backends available and connected. Otherwise it fails,
* and session is terminated.
*
* @param instance The router instance
@ -4010,7 +4010,7 @@ return_succp:
* @param backend_dcb The backend DCB
* @param action The action: ERRACT_NEW_CONNECTION or ERRACT_REPLY_CLIENT
* @param succp Result of action: true iff router can continue
*
*
* Even if succp == true connecting to new slave may have failed. succp is to
* tell whether router has enough master/slave connections to continue work.
*/
@ -4018,7 +4018,7 @@ static void handleError (
ROUTER* instance,
void* router_session,
GWBUF* errmsgbuf,
DCB* backend_dcb,
DCB* problem_dcb,
error_action_t action,
bool* succp)
{
@ -4026,10 +4026,10 @@ static void handleError (
ROUTER_INSTANCE* inst = (ROUTER_INSTANCE *)instance;
ROUTER_CLIENT_SES* rses = (ROUTER_CLIENT_SES *)router_session;
CHK_DCB(backend_dcb);
CHK_DCB(problem_dcb);
/** Don't handle same error twice on same DCB */
if (backend_dcb->dcb_errhandle_called)
if (problem_dcb->dcb_errhandle_called)
{
/** we optimistically assume that previous call succeed */
*succp = true;
@ -4037,19 +4037,23 @@ static void handleError (
}
else
{
backend_dcb->dcb_errhandle_called = true;
problem_dcb->dcb_errhandle_called = true;
}
session = backend_dcb->session;
session = problem_dcb->session;
if (session == NULL || rses == NULL)
{
*succp = false;
}
else if (dcb_isclient(problem_dcb))
{
*succp = false;
}
else
{
CHK_SESSION(session);
CHK_CLIENT_RSES(rses);
switch (action) {
case ERRACT_NEW_CONNECTION:
{
@ -4059,33 +4063,33 @@ static void handleError (
break;
}
/**
* This is called in hope of getting replacement for
* This is called in hope of getting replacement for
* failed slave(s).
*/
*succp = handle_error_new_connection(inst,
rses,
backend_dcb,
*succp = handle_error_new_connection(inst,
rses,
problem_dcb,
errmsgbuf);
rses_end_locked_router_action(rses);
break;
}
case ERRACT_REPLY_CLIENT:
{
handle_error_reply_client(session,
rses,
backend_dcb,
handle_error_reply_client(session,
rses,
problem_dcb,
errmsgbuf);
*succp = false; /*< no new backend servers were made available */
break;
break;
}
default:
*succp = false;
break;
}
}
dcb_close(backend_dcb);
dcb_close(problem_dcb);
}