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).
This commit is contained in:
antirez 2013-11-14 10:25:55 +01:00
parent e4c65e72c6
commit 69d826a354

View File

@ -1936,6 +1936,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. */
@ -1944,7 +1945,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",