From d764bb9e1f35266803cba95561b118b829fdfba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 9 Mar 2017 07:45:29 +0200 Subject: [PATCH] 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. --- server/modules/routing/readwritesplit/readwritesplit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/readwritesplit/readwritesplit.c b/server/modules/routing/readwritesplit/readwritesplit.c index dc67558a0..339ba6b39 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.c +++ b/server/modules/routing/readwritesplit/readwritesplit.c @@ -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 &&