summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2012-09-04 15:52:04 +0200
committerantirez <antirez@gmail.com>2012-09-27 13:06:05 +0200
commit1f8bd82332b7e29ed6c9e5d8b4d17948b4dce6be (patch)
treed20c3662693b3ac43b73892e7dad99708e42dd04
parentef792fc95067472494ce9c1cc179aad00ca45fae (diff)
downloadredis-1f8bd82332b7e29ed6c9e5d8b4d17948b4dce6be.tar.gz
Sentinel: more easy master redirection if master is a slave.
Before this commit Sentienl used to redirect master ip/addr if the current instance reported to be a slave only if this was the first INFO output received, and the role was found to be slave. Now instead also if we find that the runid is different, and the reported role is slave, we also redirect to the reported master ip/addr. This unifies the behavior of Sentinel in the case of a reboot (where it will see the first INFO output with the wrong role and will perform the redirection), with the behavior of Sentinel in the case of a change in what it sees in the INFO output of the master.
-rw-r--r--src/sentinel.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 659820f67..7fdc45e36 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -1426,7 +1426,7 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
/* Act if a master turned into a slave. */
if ((ri->flags & SRI_MASTER) && role == SRI_SLAVE) {
- if (first_runid && ri->slave_master_host) {
+ if ((first_runid || runid_changed) && ri->slave_master_host) {
/* If it is the first time we receive INFO from it, but it's
* a slave while it was configured as a master, we want to monitor
* its master instead. */
@@ -1445,7 +1445,7 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
if (!(ri->master->flags & SRI_FAILOVER_IN_PROGRESS) &&
(runid_changed || first_runid))
{
- /* If a slave turned into maser but:
+ /* If a slave turned into master but:
*
* 1) Failover not in progress.
* 2) RunID hs changed, or its the first time we see an INFO output.