antirez/redis — pull request #2230 by MOON-CLJ (2014-12-22 08:57:46+00:00)
Title: fix vote counter

hi, i think there is a bug in sentinelGetLeader。
in line 3311,sentinelLeaderIncr incr 1 to ri->leader, but not because ri->leader_epoch is the specified epoch.

maybe a situation。
1, sentinel1 and sentinel2 try to failover a same epoch 3349.
2, sentinel1 got most votes then continue.
3, sentinel2 not got most votes then wait.
4, then a new epoch 3352 most sentinels vote for sentinel2.
5, sentinel2 use epoch 3349 pass to sentinelGetLeader, line 3310 ri->leader_epoch == sentinel.current_epoch is true, but it's true for 3352 not for 3349.
6, so epoch 3349's failover try again, a same epoch 3349 have two failovers happened.