From 7d7b3810e7080cceeb58d39a193f06ac4585c8e7 Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 20 Feb 2014 12:13:52 +0100 Subject: [PATCH] Sentinel: report instances role switch events. This is useful mostly for debugging of issues. --- src/sentinel.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/sentinel.c b/src/sentinel.c index 9fbd43de..5de6afea 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1770,6 +1770,14 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) { ri->role_reported_time = mstime(); ri->role_reported = role; if (role == SRI_SLAVE) ri->slave_conf_change_time = mstime(); + /* Log the event with +role-change if the new role is coherent or + * with -role-change if there is a mismatch with the current config. */ + sentinelEvent(REDIS_VERBOSE, + ((ri->flags & (SRI_MASTER|SRI_SLAVE)) == role) ? + "+role-change" : "-role-change", + ri, "%@ new reported role is %s", + role == SRI_MASTER ? "master" : "slave", + ri->flags & SRI_MASTER ? "master" : "slave"); } /* Handle master -> slave role switch. */