Fix to bug #694, http://bugs.mariadb.com/show_bug.cgi?id=694
query_classifier.cc: set_query_type lost previous query type if the new was more restrictive. Problem was that if query is both READ and SESSION_WRITE and configuration parameter use_sql_variables_in=all was set, routing target became ambiguous. Replaced call to set_query_type with simply adding new type to type (=bit field) and checking unsupported combinations in readwritesplit.c:get_route_target. If such a case is met, a detailed error is written to error log in readwritesplit.c. mysql_client.c sees the error code and sends an error to client. Then mysql_client.c calls router's handleError which ensures that there are enough backend servers so that the session can continue.
This commit is contained in:
@ -870,18 +870,52 @@ int gw_read_client_event(
|
||||
}
|
||||
else
|
||||
{
|
||||
modutil_send_mysql_err_packet(dcb,
|
||||
1,
|
||||
0,
|
||||
2003,
|
||||
"HY000",
|
||||
"Write to backend failed. Session closed.");
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Routing the query failed. "
|
||||
"Session will be closed.")));
|
||||
bool succp;
|
||||
GWBUF* errbuf;
|
||||
|
||||
dcb_close(dcb);
|
||||
/**
|
||||
* Send error message indicating that routing
|
||||
* failed
|
||||
*/
|
||||
mysql_send_custom_error(
|
||||
dcb,
|
||||
1,
|
||||
0,
|
||||
"Routing query to backend failed. See "
|
||||
"the error log for further details.");
|
||||
/**
|
||||
* Create error to be sent to client if session
|
||||
* can't be continued.
|
||||
*/
|
||||
errbuf = mysql_create_custom_error(
|
||||
1,
|
||||
0,
|
||||
"Routing failed. Session is closed.");
|
||||
/**
|
||||
* Ensure that there are enough backends
|
||||
* available.
|
||||
*/
|
||||
router->handleError(
|
||||
router_instance,
|
||||
session->router_session,
|
||||
errbuf,
|
||||
dcb,
|
||||
ERRACT_NEW_CONNECTION,
|
||||
&succp);
|
||||
free(errbuf);
|
||||
/**
|
||||
* If there are not enough backends close
|
||||
* session
|
||||
*/
|
||||
if (!succp)
|
||||
{
|
||||
LOGIF(LE, (skygw_log_write_flush(
|
||||
LOGFILE_ERROR,
|
||||
"Error : Routing the query failed. "
|
||||
"Session will be closed.")));
|
||||
|
||||
dcb_close(dcb);
|
||||
}
|
||||
}
|
||||
}
|
||||
goto return_rc;
|
||||
|
Reference in New Issue
Block a user