summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-01-31 17:19:21 +0100
committerantirez <antirez@gmail.com>2013-02-11 11:47:16 +0100
commit0b50d1ce9aa27b049dde5191a1a1ff1cdde3eca4 (patch)
tree5b457f8db4da7a87b6132359850d68bfac1a01a4
parentc7b9a57fb2e50a9fc6d8734cb13ef7f48451fd2c (diff)
downloadredis-0b50d1ce9aa27b049dde5191a1a1ff1cdde3eca4.tar.gz
Sentinel: advertise the promoted slave address only after successful setup.
-rw-r--r--src/sentinel.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 8009e5ed9..fc857344c 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -2035,8 +2035,16 @@ void sentinelCommand(redisClient *c) {
} else {
sentinelAddr *addr = ri->addr;
- if ((ri->flags & SRI_FAILOVER_IN_PROGRESS) && ri->promoted_slave)
+ /* If we are in the middle of a failover, and the slave was
+ * already successfully switched to master role, we can advertise
+ * the new address as slave in order to allow clients to talk
+ * with the new master ASAP. */
+ if ((ri->flags & SRI_FAILOVER_IN_PROGRESS) &&
+ ri->promoted_slave &&
+ ri->failover_state >= SENTINEL_FAILOVER_STATE_RECONF_SLAVES)
+ {
addr = ri->promoted_slave->addr;
+ }
addReplyMultiBulkLen(c,2);
addReplyBulkCString(c,addr->ip);
addReplyBulkLongLong(c,addr->port);