Changes to readwritesplit.c:get_dcb caused regression
This commit is contained in:
VilhoRaatikka
2014-11-19 13:27:43 +02:00
parent 580f9730f6
commit 9cc0e1316c

View File

@ -1094,7 +1094,6 @@ static bool get_dcb(
*/ */
if (master_bref == NULL) if (master_bref == NULL)
{ {
succp = false;
goto return_succp; goto return_succp;
} }
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
@ -1165,30 +1164,20 @@ static bool get_dcb(
} }
/** /**
* If there are no candidates yet accept both master or * If there are no candidates yet accept both master or
* slave. If candidate is master, any slave replaces it. * slave.
*/ */
else if (candidate_bref == NULL || else if (candidate_bref == NULL)
(SERVER_IS_MASTER(candidate_bref->bref_backend->backend_server) &&
SERVER_IS_SLAVE(b->backend_server)))
{ {
/** /**
* Ensure that master has not changed dunring * Ensure that master has not changed dunring
* session and abort if it has. * session and abort if it has.
*/ */
if (SERVER_IS_MASTER(b->backend_server)) if (SERVER_IS_MASTER(b->backend_server) &&
&backend_ref[i] == master_bref)
{ {
if (candidate_bref != master_bref) /** found master */
{ candidate_bref = &backend_ref[i];
/** Log master failure */ succp = true;
succp = false;
break;
}
else
{
/** found master */
candidate_bref = &backend_ref[i];
succp = true;
}
} }
/** /**
* Ensure that max replication lag is not set * Ensure that max replication lag is not set
@ -1204,6 +1193,20 @@ static bool get_dcb(
succp = true; succp = true;
} }
} }
/**
* If candidate is master, any slave which doesn't break
* replication lag limits replaces it.
*/
else if (SERVER_IS_MASTER(candidate_bref->bref_backend->backend_server) &&
SERVER_IS_SLAVE(b->backend_server) &&
(max_rlag == MAX_RLAG_UNDEFINED ||
(b->backend_server->rlag != MAX_RLAG_NOT_AVAILABLE &&
b->backend_server->rlag <= max_rlag)))
{
/** found slave */
candidate_bref = &backend_ref[i];
succp = true;
}
/** /**
* When candidate exists, compare it against the current * When candidate exists, compare it against the current
* backend and update assign it to new candidate if * backend and update assign it to new candidate if