MXS-1743: Fix load balancing with router_options=master,slave

The code that selects the candidate backend always returned the root
master if the server bitmask contained the master bit. This should only be
done if the master bit is the only bit in the bitmask and when there are
other bits, the normal candidate selection code should be used.

Also added a query to the expanded test case to make sure the connection
actually works.
This commit is contained in:
Markus Mäkelä 2018-06-04 06:46:38 +03:00
parent da4397a501
commit d22f6d7b1c
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 6 additions and 4 deletions

View File

@ -44,9 +44,11 @@ int main(int argc, char** argv)
for (int i = 0; i < 20; i++)
{
connections.push_back(open_conn(test.maxscales->readconn_master_port[0],
test.maxscales->IP[0], "mxs1743",
"mxs1743", false));
// Open a connection and make sure it works
MYSQL* conn = open_conn(test.maxscales->readconn_master_port[0], test.maxscales->IP[0],
"mxs1743", "mxs1743", false);
test.try_query(conn, "SELECT 1");
connections.push_back(conn);
}
// Give the connections a few seconds to establish

View File

@ -344,7 +344,7 @@ newSession(MXS_ROUTER *instance, MXS_SESSION *session)
continue;
}
if (ref == master_host && (inst->bitvalue & SERVER_MASTER))
if (ref == master_host && inst->bitvalue == SERVER_MASTER)
{
/* If option is "master" return only the root Master as there could be
* intermediate masters (Relay Servers) and they must not be selected.