summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2013-12-06 12:46:56 +0100
committerantirez <antirez@gmail.com>2013-12-06 12:49:27 +0100
commitfba0b23e724e86ef6b98f07594cec3b45b8a9ab9 (patch)
treeffec2fc18967082fd933992e405c2d72cfa45ad2
parentdceaca1f699ef33a05905ec9c545cbc059143463 (diff)
downloadredis-fba0b23e724e86ef6b98f07594cec3b45b8a9ab9.tar.gz
Sentinel: fix reported role info sampling.
The way the role change was recoded was not sane and too much convoluted, causing the role information to be not always updated. This commit fixes issue #1445.
-rw-r--r--src/sentinel.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/sentinel.c b/src/sentinel.c
index 63df3fb6d..909f7e8ea 100644
--- a/src/sentinel.c
+++ b/src/sentinel.c
@@ -1764,22 +1764,22 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
* Some things will not happen if sentinel.tilt is true, but some will
* still be processed. */
+ /* Remember when the role changed. */
+ if (role != ri->role_reported) {
+ ri->role_reported_time = mstime();
+ ri->role_reported = role;
+ if (role == SRI_SLAVE) ri->slave_conf_change_time = mstime();
+ }
+
/* Handle master -> slave role switch. */
if ((ri->flags & SRI_MASTER) && role == SRI_SLAVE) {
- if (ri->role_reported != SRI_SLAVE) {
- ri->role_reported_time = mstime();
- ri->role_reported = SRI_SLAVE;
- ri->slave_conf_change_time = mstime();
- }
+ /* Nothing to do, but masters claiming to be slaves are
+ * considered to be unreachable by Sentinel, so eventually
+ * a failover will be triggered. */
}
/* Handle slave -> master role switch. */
if ((ri->flags & SRI_SLAVE) && role == SRI_MASTER) {
- if (ri->role_reported != SRI_MASTER) {
- ri->role_reported_time = mstime();
- ri->role_reported = SRI_MASTER;
- }
-
/* If this is a promoted slave we can change state to the
* failover state machine. */
if (!sentinel.tilt &&