You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Slave does not become master if original master never showed up or both restart #1073
I have to scenarios where Sentinel does not promote a master. Some might say that this could be an akward situation that should not happen, but when in the cloud IAAS, it can happen rather frequently. For example instances go down, or reprovisionned. Or simply when your app and redis replicaset is started only a few hours of the day or intermittently. Whatever the reason, when the whole set of servers is started, Redis replicaset should be operational even if the redis-server which is master in its configuration does not show up for various reasons.
Below are 2 scenarios to reproduce the case
My setup is 2x redis servers, and 3x sentinels, on 3 different servers.
I am using the lastest redis-server from branch 2.6, currently at commit antirez@34a57a5
Scenario 1:
there are 2 redis servers configured as master slave, namely redis1 and redis2. They are not started
there are 3 sentinels that are running fine
i start redis2 which has slaveof redis1 in its configuration
-> BAD: sentinels do not promote redis2 to master
Scenario 2:
there are 2 redis servers configured as master slave, namely redis1 and redis2. They are not started
there are 3 sentinels that are running fine
i start redis1 which is master in its configuration. It shows up as master
i start redis2 which has slaveof redis1 in its configuration. It shows up as a slave and begins syncing
i stop redis1
sentinels promote redis2 to master, as expected
i stop redis2
i start redis2. It tries to sync but redis1 is still down
-> BAD: sentinels do not promote redis2 to master. The difference with scenario1 is that sentinels had the history and saw the topology of the redis replicaset, when both redis1 and redis2 were running, but they did not take it into account to promote redis2 as master.
Hello, long reply monday but to give you a fast feedback, may you retry scenario 2 with latest 2.6 branch commit? I believe we solved it. First case is a bit more dangerous and I'll comment in a detailed way. Cheers
I tried the commit antirez@d964979 but make test fails on Amazon 2012.09 : redis-server processes becomes defunct and unkillable, and make test never completes.
So i will test Sentinel again some time later
make && make test . I did Not have failing tests, but it could not complete and created some redis-server processes which ended up defunct and one supposedly running, all unkillable. At the same time the make test is spilling out messages something like waiting forked redis XXXX to end or something like this. I'll try to resume this but much later
Nothing I'm aware of should break testing on EC2, maybe just out of memory or alike... I'll ask uses on twitter to replicate on some EC2 instance. Thanks.
That was a micro instance, because i was planning to do just sentinel tests and not load testing Redis, so memory or cpu deprivation might be the culprits there
On Thursday 2 May 2013 at 17:02, Salvatore Sanfilippo wrote:
Nothing I'm aware of should break testing on EC2, maybe just out of memory or alike... I'll ask uses on twitter to replicate on some EC2 instance. Thanks.
This sounds like a kernel panic or alike :-) Btw it is likely the result of out of memory.
Probably it is still possible to run the Redis test in micro instances using:
./runtest --clients 1
This is usually automatically triggered when a very slow box is detected, but probably not in that case.
TL;DR for the original poster @alexfouche, this is not a Redis issue and you can skip testing at all if you want to try the Sentinel improvements later at some point.
I too am on redis-2.6.13 and also see the scenario2 that @alexfouche pointed out. Unless the master is brought back again, the situation does not change.
I have the same issue with version 2.8.2 but only 2 sentinels and 2 servers. Each server has one redis instance and one sentinel instance running. The quorum needed to detect odown is just 1 in this case and is detected fine.
However, when I just kill the master server, thus leaving just 1 redis and 1 sentinel instance then this instance repeatedly tries to promote the old master but never tries to promote the previous slave.
@antirez so that means running only 2 or fewer sentinels will never work since there cannot be a majority (if one goes down for 2)?
This is never mentioned in the documentation and good to know. It somewhat limits usability.
Running two Sentinels works great as long as no Sentinel becomes not available at the same time the master becomes not available. In the new documentation online it is mentioned in:
The Sentinel documentation, section "Configuring Sentinel".
The Sentinel example sentinel.conf provided with the 2.8.x source code.
You probably read the old documentation of Sentinel, at the same url as before there is the new one with more information.
I totally understand your point of view, if you have just two physical servers you can't reach majority if one is partitioned away, however this makes the new Sentinel implementation much more reliable.
Note that it is totally fine to run the third Sentinel in the front end servers. If one Redis server fails, the majority and the failover will be performed by the other Redis server and the other instance running in the front end.
Thank you for the clarification. I have a somewhat even smaller setup at the moment where I have 2 frontend servers which use redis simply as an in memory cache for signalr. I run sentinel on the same instances and this creates the unsupported case you describe that 1 sentinel instance will always go down together with one redis instance and possibly the master.
I will think about a solution to this case and possibly just add another server. I will work great then, great work!
Your situation is basically unsolvable unfortunately! If Sentinel would promote the master without agreement you could end with split-brain condition where both the sides are masters and receiving writes... big inconsistency times ;-)
Thanks.
If I may, it also doesn't seem like the best fit for Sentinel. I'd set up the two redis servers to be independent and do consistent hashing on the web boxes (many drivers support this by default, though you might need to catch connection failures and rebuild the ring yourself)
we hit the split-brain condition and the apps ran into writing to two different masters.
Our Setup: Redis1 Master & Redis2 Slave in Primary DC. Redis3 Slave & Redis4 Slave in Secondary DC.
Scenario -
-Network disruption happened between the DCs and lost communication.
-Secondary DC Redis3 Slave could not reach the master, has been elected as new master
-Network connectivity has been restored, Apps found two masters and started writing to both
-Fortunately the election happened again so quickly, old master stayed back in its role, the new master stepped back as slave. unfortunately there happened to be a minor disruption in the App.
Does Sentinel is the solution for this scenario? we don't use Sentinel as of now.
Whom we need to consider to be working smarter in this case? App which connecting to Redis or Redis itself? Please advise. Thanks.
@ramerang Hello, Sentinel attempts to avoid this kind of issues only in a best effort way, there is no guarantee that the old master will not get writes that will be lost. However Redis can be configured (check the Sentinel doc for more info) in order for isolated masters to stop accepting writes ASAP (in a configurable number of seconds) when they cannot reach the other slaves, so that isolated masters will be unlikely to accept writes.
In practical terms this means that Sentinel + proper Redis configuration will attempt (in a best effort way) to:
Avoid to accept writes in old-master + clients in the same partition.
Attempt to reconfigure the returning master ASAP as slave when it returns back.
Update the clients configuration ASAP after a failover, if the clients follow the Sentinel client protocol.
Activity
antirez commentedon Apr 27, 2013
Hello, long reply monday but to give you a fast feedback, may you retry scenario 2 with latest 2.6 branch commit? I believe we solved it. First case is a bit more dangerous and I'll comment in a detailed way. Cheers
alexfouche commentedon May 2, 2013
I tried the commit antirez@d964979 but make test fails on Amazon 2012.09 : redis-server processes becomes defunct and unkillable, and make test never completes.
So i will test Sentinel again some time later
antirez commentedon May 2, 2013
Hello @alexfouche, you mean, your own test fails? or Redis "Make test"? Thank you.
alexfouche commentedon May 2, 2013
make && make test. I did Not have failing tests, but it could not complete and created some redis-server processes which ended up defunct and one supposedly running, all unkillable. At the same time the make test is spilling out messages something like waiting forked redis XXXX to end or something like this. I'll try to resume this but much laterantirez commentedon May 2, 2013
Nothing I'm aware of should break testing on EC2, maybe just out of memory or alike... I'll ask uses on twitter to replicate on some EC2 instance. Thanks.
alexfouche commentedon May 2, 2013
That was a micro instance, because i was planning to do just sentinel tests and not load testing Redis, so memory or cpu deprivation might be the culprits there
Alexandre Fouche
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Thursday 2 May 2013 at 17:02, Salvatore Sanfilippo wrote:
karlseguin commentedon May 2, 2013
make testfor antirez@d964979 worked fine on a m3.xlargeon a micro I got stuck in a "forcing process XXX to exit" after many tests (all?) had run.
Similar stuff for redis-server
antirez commentedon May 2, 2013
This sounds like a kernel panic or alike :-) Btw it is likely the result of out of memory.
Probably it is still possible to run the Redis test in micro instances using:
./runtest --clients 1
This is usually automatically triggered when a very slow box is detected, but probably not in that case.
TL;DR for the original poster @alexfouche, this is not a Redis issue and you can skip testing at all if you want to try the Sentinel improvements later at some point.
antirez commentedon May 2, 2013
p.s. @karlseguin thank you! Very appreciated.
alexfouche commentedon May 6, 2013
I tested with 2.6.13, and i do not see it fixed. Here is scenario2 from Sentinel point of view:
Sentinels started, redis1 and 2 stopped
Starting of redis1
Starting of redis2
Stopping of redis1, redis2 is promoted
Stopping of redis2
Start of redis2. redis2 is NOT promoted
Atreyee commentedon May 20, 2013
Hi,
I too am on redis-2.6.13 and also see the scenario2 that @alexfouche pointed out. Unless the master is brought back again, the situation does not change.
orangey commentedon Oct 21, 2013
Scenario 1 problem still exists in redis-2.6.16
technicallyfeasible commentedon Dec 5, 2013
I have the same issue with version 2.8.2 but only 2 sentinels and 2 servers. Each server has one redis instance and one sentinel instance running. The quorum needed to detect odown is just 1 in this case and is detected fine.
However, when I just kill the master server, thus leaving just 1 redis and 1 sentinel instance then this instance repeatedly tries to promote the old master but never tries to promote the previous slave.
antirez commentedon Dec 5, 2013
@technicallyfeasible new Sentinel requires majority in order to perform the failover, whatever the quorum for the ODOWN is set.
technicallyfeasible commentedon Dec 5, 2013
@antirez so that means running only 2 or fewer sentinels will never work since there cannot be a majority (if one goes down for 2)?
This is never mentioned in the documentation and good to know. It somewhat limits usability.
antirez commentedon Dec 5, 2013
Running two Sentinels works great as long as no Sentinel becomes not available at the same time the master becomes not available. In the new documentation online it is mentioned in:
You probably read the old documentation of Sentinel, at the same url as before there is the new one with more information.
I totally understand your point of view, if you have just two physical servers you can't reach majority if one is partitioned away, however this makes the new Sentinel implementation much more reliable.
Note that it is totally fine to run the third Sentinel in the front end servers. If one Redis server fails, the majority and the failover will be performed by the other Redis server and the other instance running in the front end.
technicallyfeasible commentedon Dec 5, 2013
Thank you for the clarification. I have a somewhat even smaller setup at the moment where I have 2 frontend servers which use redis simply as an in memory cache for signalr. I run sentinel on the same instances and this creates the unsupported case you describe that 1 sentinel instance will always go down together with one redis instance and possibly the master.
I will think about a solution to this case and possibly just add another server. I will work great then, great work!
antirez commentedon Dec 5, 2013
Your situation is basically unsolvable unfortunately! If Sentinel would promote the master without agreement you could end with split-brain condition where both the sides are masters and receiving writes... big inconsistency times ;-)
Thanks.
karlseguin commentedon Dec 6, 2013
If I may, it also doesn't seem like the best fit for Sentinel. I'd set up the two redis servers to be independent and do consistent hashing on the web boxes (many drivers support this by default, though you might need to catch connection failures and rebuild the ring yourself)
ramerang commentedon Jun 21, 2016
we hit the split-brain condition and the apps ran into writing to two different masters.
Our Setup: Redis1 Master & Redis2 Slave in Primary DC. Redis3 Slave & Redis4 Slave in Secondary DC.
Scenario -
-Network disruption happened between the DCs and lost communication.
-Secondary DC Redis3 Slave could not reach the master, has been elected as new master
-Network connectivity has been restored, Apps found two masters and started writing to both
-Fortunately the election happened again so quickly, old master stayed back in its role, the new master stepped back as slave. unfortunately there happened to be a minor disruption in the App.
Does Sentinel is the solution for this scenario? we don't use Sentinel as of now.
Whom we need to consider to be working smarter in this case? App which connecting to Redis or Redis itself? Please advise. Thanks.
antirez commentedon Jul 5, 2016
@ramerang Hello, Sentinel attempts to avoid this kind of issues only in a best effort way, there is no guarantee that the old master will not get writes that will be lost. However Redis can be configured (check the Sentinel doc for more info) in order for isolated masters to stop accepting writes ASAP (in a configurable number of seconds) when they cannot reach the other slaves, so that isolated masters will be unlikely to accept writes.
In practical terms this means that Sentinel + proper Redis configuration will attempt (in a best effort way) to:
Squashed 'deps/hiredis/' changes from f8de9a4bd..b6a052fe0