This commit is contained in:
Mark Riddoch
2014-11-19 12:07:13 +00:00
2 changed files with 23 additions and 18 deletions

View File

@ -1245,6 +1245,7 @@ static void enable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
session_enable_log(session,type); session_enable_log(session,type);
return; return;
} }
session = session->next;
} }
dcb_printf(dcb, "Session not found: %s\n", arg2); dcb_printf(dcb, "Session not found: %s\n", arg2);
@ -1287,6 +1288,7 @@ static void disable_sess_log_action(DCB *dcb, char *arg1, char *arg2)
session_disable_log(session,type); session_disable_log(session,type);
return; return;
} }
session = session->next;
} }
dcb_printf(dcb, "Session not found: %s\n", arg2); dcb_printf(dcb, "Session not found: %s\n", arg2);

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