diff options
author | antirez <antirez@gmail.com> | 2013-11-14 10:25:55 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-11-21 15:21:30 +0100 |
commit | e15ba6a6972f7e20fe92340b6d92fd6b73119d52 (patch) | |
tree | 98f2f4cad422c25a162dfd36abd75619d49a3450 | |
parent | 1a6abe7d79689b43debad0cf55b91063a1fd2119 (diff) | |
download | redis-e15ba6a6972f7e20fe92340b6d92fd6b73119d52.tar.gz |
Sentinel: fix address of master in Hello messages.
Once we switched configuration during a failover, we should advertise
the new address.
This was a serious race condition as the Sentinel performing the
failover for a moment advertised the old address with the new
configuration epoch: once trasmitted to the other Sentinels the broken
configuration would remain there forever, until the next failover
(because a greater configuration epoch is required to overwrite an older
one).
-rw-r--r-- | src/sentinel.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/sentinel.c b/src/sentinel.c index eff6f0d3f..ae1887e97 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1938,6 +1938,7 @@ void sentinelPingInstance(sentinelRedisInstance *ri) { char payload[REDIS_IP_STR_LEN+1024]; sentinelRedisInstance *master = (ri->flags & SRI_MASTER) ? ri : ri->master; + sentinelAddr *master_addr = sentinelGetCurrentMasterAddress(master); snprintf(payload,sizeof(payload), "%s,%d,%s,%d,%llu," /* Info about this sentinel. */ @@ -1946,7 +1947,7 @@ void sentinelPingInstance(sentinelRedisInstance *ri) { (master->flags & SRI_CAN_FAILOVER) != 0, (unsigned long long) sentinel.current_epoch, /* --- */ - master->name,master->addr->ip,master->addr->port, + master->name,master_addr->ip,master_addr->port, master->config_epoch); retval = redisAsyncCommand(ri->cc, sentinelPublishReplyCallback, NULL, "PUBLISH %s %s", |