Active replicas referencing eachother should connect one at a time
Former-commit-id: c0c033a0c175eebdf2173e6e4e59e792d2fe4285
This commit is contained in:
parent
8740fb79af
commit
da309f7045
@ -1121,6 +1121,25 @@ void processReplconfUuid(client *c, robj *arg)
|
||||
if (uuid_parse(remoteUUID, c->uuid) != 0)
|
||||
goto LError;
|
||||
|
||||
listIter liMi;
|
||||
listNode *lnMi;
|
||||
listRewind(g_pserver->masters, &liMi);
|
||||
|
||||
// Enforce a fair ordering for connection, if they attempt to connect before us close them out
|
||||
// This must be consistent so that both make the same decision of who should proceed first
|
||||
while ((lnMi = listNext(&liMi))) {
|
||||
redisMaster *mi = (redisMaster*)listNodeValue(lnMi);
|
||||
if (mi->repl_state == REPL_STATE_CONNECTED)
|
||||
continue;
|
||||
if (FSameUuidNoNil(mi->master_uuid, c->uuid)) {
|
||||
// Decide based on UUID so both clients make the same decision of which host loses
|
||||
// otherwise we may entere a loop where neither client can proceed
|
||||
if (memcmp(mi->master_uuid, c->uuid, UUID_BINARY_LEN) < 0) {
|
||||
freeClientAsync(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char szServerUUID[36 + 2]; // 1 for the '+', another for '\0'
|
||||
szServerUUID[0] = '+';
|
||||
uuid_unparse(cserver.uuid, szServerUUID+1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user