Prevent a spurious +sdown event on switch.
When we reset the master we should start with clean timestamps for ping replies otherwise we'll detect a spurious +sdown event, because on +master-switch event the previous master instance was probably in +sdown condition. Since we updated the address we should count time from scratch again. Also this commit makes sure to explicitly reset the count of pending commands, now we can do this because of the new way the hiredis link is closed.
This commit is contained in:
parent
66b8296c55
commit
b94bca01fc
@ -765,6 +765,7 @@ void sentinelResetMaster(sentinelRedisInstance *ri, int flags) {
|
||||
ri->sentinels = dictCreate(&instancesDictType,NULL);
|
||||
if (ri->cc) sentinelKillLink(ri,ri->cc);
|
||||
if (ri->pc) sentinelKillLink(ri,ri->pc);
|
||||
ri->pending_commands = 0;
|
||||
ri->flags &= SRI_MASTER|SRI_CAN_FAILOVER|SRI_DISCONNECTED;
|
||||
if (ri->leader) {
|
||||
sdsfree(ri->leader);
|
||||
@ -778,6 +779,8 @@ void sentinelResetMaster(sentinelRedisInstance *ri, int flags) {
|
||||
sdsfree(ri->slave_master_host);
|
||||
ri->runid = NULL;
|
||||
ri->slave_master_host = NULL;
|
||||
ri->last_avail_time = mstime();
|
||||
ri->last_pong_time = mstime();
|
||||
if (flags & SENTINEL_GENERATE_EVENT)
|
||||
sentinelEvent(REDIS_WARNING,"+reset-master",ri,"%@");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user