mirror of
https://github.com/fluencelabs/redis
synced 2025-03-18 16:40:50 +00:00
Sentinel: fix cross-master Sentinel address update.
This commit both fixes the crash reported with issue #3364 and also properly closes the old links after the Sentinel address for the other masters gets updated. The two problems where: 1. The Sentinel that switched address may not monitor all the masters, it is possible that there is no match, and the 'match' variable is NULL. Now we check for no match and 'continue' to the next master. 2. By ispecting the code because of issue "1" I noticed that there was a problem in the code that disconnects the link of the Sentinel that needs the address update. Basically link->disconnected is non-zero even if just *a single link* (cc -- command link or pc -- pubsub link) are disconnected, so to check with if (link->disconnected) in order to close the links risks to leave one link connected. I was able to manually reproduce the crash at "1" and verify that the commit resolves the issue. Close #3364.
This commit is contained in:
parent
b2cc8bccdb
commit
c383be3b0f
@ -1062,11 +1062,18 @@ int sentinelUpdateSentinelAddressInAllMasters(sentinelRedisInstance *ri) {
|
||||
sentinelRedisInstance *master = dictGetVal(de), *match;
|
||||
match = getSentinelRedisInstanceByAddrAndRunID(master->sentinels,
|
||||
NULL,0,ri->runid);
|
||||
if (match->link->disconnected == 0) {
|
||||
/* If there is no match, this master does not know about this
|
||||
* Sentinel, try with the next one. */
|
||||
if (match == NULL) continue;
|
||||
|
||||
/* Disconnect the old links if connected. */
|
||||
if (match->link->cc != NULL)
|
||||
instanceLinkCloseConnection(match->link,match->link->cc);
|
||||
if (match->link->pc != NULL)
|
||||
instanceLinkCloseConnection(match->link,match->link->pc);
|
||||
}
|
||||
|
||||
if (match == ri) continue; /* Address already updated for it. */
|
||||
|
||||
/* Update the address of the matching Sentinel by copying the address
|
||||
* of the Sentinel object that received the address update. */
|
||||
releaseSentinelAddr(match->addr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user