mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Sentinel: handle SRI_PROMOTED flag correctly.
Lack of check of the SRI_PROMOTED flag caused Sentienl to act with the promoted slave turned into a master during failover like if it was a normal instance. Normally this problem was not apparent because during real failovers the old master is down so the bugged code path was not entered, however with manual failovers via the SENTINEL FAILOVER command, the problem was easily triggered. This commit prevents promoted slaves from getting reconfigured, moreover we now explicitly check that during a failover the slave turning into a master is the one we selected for promotion and not a different one.
This commit is contained in:
parent
1c343ec29f
commit
94bc467328
@ -1902,7 +1902,8 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
|
||||
if ((ri->flags & SRI_SLAVE) && role == SRI_MASTER) {
|
||||
/* If this is a promoted slave we can change state to the
|
||||
* failover state machine. */
|
||||
if ((ri->master->flags & SRI_FAILOVER_IN_PROGRESS) &&
|
||||
if ((ri->flags & SRI_PROMOTED) &&
|
||||
(ri->master->flags & SRI_FAILOVER_IN_PROGRESS) &&
|
||||
(ri->master->failover_state ==
|
||||
SENTINEL_FAILOVER_STATE_WAIT_PROMOTION))
|
||||
{
|
||||
@ -1926,9 +1927,10 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
|
||||
* going forward, to receive new configs if any. */
|
||||
mstime_t wait_time = SENTINEL_PUBLISH_PERIOD*4;
|
||||
|
||||
if (sentinelMasterLooksSane(ri->master) &&
|
||||
sentinelRedisInstanceNoDownFor(ri,wait_time) &&
|
||||
mstime() - ri->role_reported_time > wait_time)
|
||||
if (!(ri->flags & SRI_PROMOTED) &&
|
||||
sentinelMasterLooksSane(ri->master) &&
|
||||
sentinelRedisInstanceNoDownFor(ri,wait_time) &&
|
||||
mstime() - ri->role_reported_time > wait_time)
|
||||
{
|
||||
int retval = sentinelSendSlaveOf(ri,
|
||||
ri->master->addr->ip,
|
||||
|
Loading…
x
Reference in New Issue
Block a user