MXS-1178: Fix master_accept_reads

The order of the servers in the service definition could break the
master_accept_reads functionality.

When the first server defined in the service is a slave, it will always be
picked as the first candidate for reads. The master would only be
considered as a candidate for reads if no previous candidate was
available. For this reason, the master_accept_reads only worked when the
first server in the list was the master.
This commit is contained in:
Markus Mäkelä
2017-03-09 07:45:29 +02:00
parent fd2df3a863
commit d764bb9e1f

View File

@ -1236,7 +1236,8 @@ static bool get_dcb(DCB **p_dcb, ROUTER_CLIENT_SES *rses, backend_type_t btype,
* backend and update assign it to new candidate if
* necessary.
*/
else if (SERVER_IS_SLAVE(&server))
else if (SERVER_IS_SLAVE(&server) ||
(rses->rses_config.rw_master_reads && SERVER_IS_MASTER(&server)))
{
if (max_rlag == MAX_RLAG_UNDEFINED ||
(b->backend_server->rlag != MAX_RLAG_NOT_AVAILABLE &&