Added new error action to router.h, added functionality to reset error flag from DCB in handleError. Error is reset before every new routing call.
This commit is contained in:
VilhoRaatikka
2015-01-16 11:13:42 +02:00
parent c5c9165a26
commit da77da803b
3 changed files with 35 additions and 17 deletions

View File

@ -68,7 +68,8 @@ typedef void *ROUTER;
*/ */
typedef enum error_action { typedef enum error_action {
ERRACT_NEW_CONNECTION = 0x001, ERRACT_NEW_CONNECTION = 0x001,
ERRACT_REPLY_CLIENT = 0x002 ERRACT_REPLY_CLIENT = 0x002,
ERRACT_RESET = 0x004
} error_action_t; } error_action_t;

View File

@ -843,6 +843,8 @@ int gw_read_client_event(
} }
else else
{ {
router->handleError(NULL, NULL, NULL, dcb, ERRACT_RESET, NULL);
if (stmt_input) if (stmt_input)
{ {
/** /**
@ -874,15 +876,23 @@ int gw_read_client_event(
GWBUF* errbuf; GWBUF* errbuf;
/** /**
* Send error message indicating that routing * Create error to be sent to client if session
* failed * can't be continued.
*/ */
mysql_send_custom_error( errbuf = mysql_create_custom_error(
dcb,
1, 1,
0, 0,
"Routing query to backend failed. See " "Routing query to backend failed. See "
"the error log for further details."); "the error log for further details.");
router->handleError(
router_instance,
session->router_session,
errbuf,
dcb,
ERRACT_REPLY_CLIENT,
&succp);
free(errbuf);
/** /**
* Create error to be sent to client if session * Create error to be sent to client if session
* can't be continued. * can't be continued.
@ -1587,7 +1597,7 @@ static int route_by_statement(
goto return_rc; goto return_rc;
} }
} }
while (*p_readbuf != NULL); while (rc == 1 && *p_readbuf != NULL);
return_rc: return_rc:
return rc; return rc;

View File

@ -4407,6 +4407,13 @@ static void handleError (
CHK_DCB(backend_dcb); CHK_DCB(backend_dcb);
/** Reset error handle flag from a given DCB */
if (action == ERRACT_RESET)
{
backend_dcb->dcb_errhandle_called = false;
return;
}
/** Don't handle same error twice on same DCB */ /** Don't handle same error twice on same DCB */
if (backend_dcb->dcb_errhandle_called) if (backend_dcb->dcb_errhandle_called)
{ {