MXS-2313: Use servers of same rank in readwritesplit

When a readwritesplit session has a connection to a master server, servers
of the same rank as the master are used. If no master connection is
available, the server with the highest rank among all connected servers is
used. If there are no open connections, the server with the best rank is
chosen and a connection to it is made.

Connections with different rank values than what is the current rank value
of the session will be discarded. This reduces the use of server with
different ranks when the master server of a session fails. Without the
active pruning of connections, slave connections to primary clusters
without masters would remain in use even after the primary master
fails. This guarantees full switchover to a secondary cluster if a master
change occurs.
This commit is contained in:
Markus Mäkelä
2019-03-13 11:11:40 +02:00
parent 109702ee72
commit 4bf9fa872c
3 changed files with 73 additions and 29 deletions

View File

@ -144,6 +144,7 @@ private:
bool route_stored_query();
void close_stale_connections();
int64_t get_current_rank();
mxs::RWBackend* get_hinted_backend(char* name);
mxs::RWBackend* get_slave_backend(int max_rlag);
mxs::RWBackend* get_master_backend();