Don't redirect duplicate connections

The redirection method checks if a slave connection to the redirection
target already exists. If so, the connection is not modified. Also, failover
better detects duplicate connections during promotion.
This commit is contained in:
Esa Korhonen
2018-10-11 18:44:30 +03:00
parent e930270b9c
commit 0c203fa02d
3 changed files with 130 additions and 53 deletions

View File

@ -1838,6 +1838,8 @@ bool MariaDBServer::merge_slave_conns(ClusterOperation& op, const SlaveStatusArr
auto conn_can_be_merged = [this](const SlaveStatus& slave_conn, string* ignore_reason_out) -> bool {
bool accepted = true;
auto master_id = slave_conn.master_server_id;
string my_host = m_server_base->server->address;
int my_port = m_server_base->server->port;
// The connection is only merged if it satisfies the copy-conditions. Merging has also
// additional requirements.
string ignore_reason;
@ -1851,6 +1853,11 @@ bool MariaDBServer::merge_slave_conns(ClusterOperation& op, const SlaveStatusArr
accepted = false;
ignore_reason = string_printf("it points to %s (according to server id:s).", name());
}
else if (slave_conn.master_host == my_host && slave_conn.master_port == my_port)
{
accepted = false;
ignore_reason = string_printf("it points to %s (according to master host:port).", name());
}
else
{
// Compare to connections already existing on this server.