Skip to content

Manual failover does not work #1557

Closed
Closed

Description

@korpa

I installed a redis cluster (3.0 beta1) and added 4 nodes:

  • 2 masters
  • 2 slaves

This works as expected.

Then I used redis-cli to connect to one of the slaves and tried a manual failover described in http://redis.io/topics/cluster-tutorial. The CLI says OK:

127.0.0.1:6382> cluster failover
OK

But the logfile tells a different story:

[2628] 20 Feb 11:03:14.615 # Manual failover user request accepted.
[2628] 20 Feb 11:03:14.619 # Received replication offset for paused master manual failover: 3930427
[2628] 20 Feb 11:03:14.642 # All master replication stream processed, manual failover can start.
[2628] 20 Feb 11:03:14.642 # Start of election delayed for 0 milliseconds (rank #0, offset 3930427).
[2628] 20 Feb 11:03:14.743 # Start of election delayed for 0 milliseconds (rank #0, offset 3930427).
.
.
.
[2628] 20 Feb 11:03:19.357 # Start of election delayed for 0 milliseconds (rank #0, offset 3930427).
[2628] 20 Feb 11:03:19.457 # Start of election delayed for 0 milliseconds (rank #0, offset 3930427).
[2628] 20 Feb 11:03:19.558 # Start of election delayed for 0 milliseconds (rank #0, offset 3930427).
[2628] 20 Feb 11:03:19.658 # Manual failover timed out.

Somewhere I read that automatic failovers only work, if you have a least 3 masters. So I thought, maybe I need a third master for manual failovers as well. So I created a new node and added to the cluster. But I did NOT reshard it (new master has no slots), as I just need it for the ellection. But sadly this does not help. I get the same errors in the logfile.

Can someone help? What do I need to do, to make a manual failover?

Thanks.

Activity

  1. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Hello, masters without slots does not participate to elections. This is useful since the obvious way to add a new node to the cluster is as a master, and you don't want your quorum to change just because you are attaching some new instance that may be configured as a slave a second after.

    So, just reshard a few slots to the new master and everything should work. To reshard simply use redis-trib. Keeping the ticket open to check if this fixes the issue.

  2. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    No wait... here the problem is probably different, investigating.

  3. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Ok, what is your configured node-timeout in redis.conf?

  4. korpa commented on Feb 20, 2014

    @korpa
    Author

    Hi @antirez,

    thanks for the reply. Timeout is:

    cluster-node-timeout 5
    

    What I don't understand: Do I need at least 3 masters (with shards as I learned now :) ) for a manual failover as well or should a manual failover work with two masters as well?

  5. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Ok I think the problem is in this cluster-node-timeout 5. Now the timeout is in milliseconds, so you want 5000 instead :-) And yes because in the manual failover there are both masters up... actually both can vote so with 2 should work. But usually this will not work as with 2 the majority is 2/2+1 that is ... 2, and if one is down, no way.

  6. korpa commented on Feb 20, 2014

    @korpa
    Author

    I used a config-file I used with a testcluster half a year ago. Just updated the timeout to 5000 and did the failover again. Now it worked. Thank you very much.

    Now my old master is still a master, but without shards. I have to make it a slave manually. Wouldn't it be better, if the old master automatically gets the slave of the new master?

  7. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Hello korpa, actually your old master should automatically turn into a slave, can you retry to see if it works, and otherwise send some log about what happens? Maybe what you see still as master is the other empty master you added for failover concerns?

  8. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    p.s. to start please just send CLUSTR NODES output.

  9. korpa commented on Feb 20, 2014

    @korpa
    Author

    Hi @antirez,

    Please see the output below. :6385 was this third empty master. :6384 was the old master for shards 8192-16383. After the the failover :6382 is the new master (myself). You see, that :6384 is now an empty master

    127.0.0.1:6382> cluster nodes
    90f7f3693753fcd654177128f07a11fc65aeefd2 127.0.0.1:6381 slave 07d70ff010c745fd557335ee41ca34cad9490be2 0 1392892567360 0 connected
    07d70ff010c745fd557335ee41ca34cad9490be2 127.0.0.1:6383 master - 0 1392892566357 0 connected 0-8191
    93c01f03ad2170a42de960669659edfa24212736 :0 myself,master - 0 0 1 connected 8192-16383
    eebe79ad3c9df4c5b991c2315c9e2f91e7f97df7 127.0.0.1:6385 master - 0 1392892567860 0 connected
    6ca35fa472366e0c4d8136609ad2f57a14564ac8 127.0.0.1:6384 master - 0 1392892566858 0 connected
    
  10. korpa commented on Feb 20, 2014

    @korpa
    Author

    Now I did a failover for the other master as well. But it is very wired now. Both old masters are slaves now. But the pairs changed:

    cluster nodes
    eebe79ad3c9df4c5b991c2315c9e2f91e7f97df7 127.0.0.1:6385 master - 0 1392894118538 0 connected
    07d70ff010c745fd557335ee41ca34cad9490be2 127.0.0.1:6383 slave 93c01f03ad2170a42de960669659edfa24212736 0 1392894118037 2 connected
    93c01f03ad2170a42de960669659edfa24212736 127.0.0.1:6382 master - 0 1392894117537 1 connected 8192-16383
    6ca35fa472366e0c4d8136609ad2f57a14564ac8 127.0.0.1:6384 slave 90f7f3693753fcd654177128f07a11fc65aeefd2 0 1392894117537 2 connected
    90f7f3693753fcd654177128f07a11fc65aeefd2 :0 myself,master - 0 0 2 connected 0-8191
    

    Before manual failover:
    master 6383 => slave 6381
    master 6384 => slave 6382

    After manual failover:
    master 6381 => slave 6384
    master 6382 => slave 6383

  11. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    It should never happened what you observed (that the master does not turn as a slave when it loses its last slot), maybe there is an issue with manual failover, however it is strange that later the instance appears as a slave, did you configured it manually with CLUSTER REPLICATE?

    Btw to start I'm creating your exact setup to see if I'm missing something.

    Btw, if you do a normal failover stopping instances, everything is working as expected?

    About pairs changing, depending on what happened exactly, this is possible because of replicas migration, please could you check the log to see if this was the case?

    Reproducing your setup right now.

  12. korpa commented on Feb 20, 2014

    @korpa
    Author

    I did not a CLUSTER REPLICATE:

    I extracted the failover logs from all four logfiles. Especially line 4 of the 6383 looks strange to me.

    [13195] 20 Feb 12:01:51.552 # Migrating to orphaned master 93c01f03ad2170a42de960669659edfa24212736
    

    Why does it migrate to 93c01f03ad2170a42de960669659edfa24212736?

    6381 - 90f7f3693753fcd654177128f07a11fc65aeefd2
    
    [5956] 20 Feb 12:01:50.846 # Manual failover user request accepted.
    [5956] 20 Feb 12:01:50.947 # Received replication offset for paused master manual failover: 5581934
    [5956] 20 Feb 12:01:51.023 # All master replication stream processed, manual failover can start.
    [5956] 20 Feb 12:01:51.023 # Start of election delayed for 0 milliseconds (rank #0, offset 5581934).
    [5956] 20 Feb 12:01:51.123 # Starting a failover election for epoch 2.
    [5956] 20 Feb 12:01:51.177 # Failover election won: I'm the new master.
    [5956] 20 Feb 12:01:51.177 # Connection with master lost.
    [5956] 20 Feb 12:01:51.177 * Caching the disconnected master state.
    [5956] 20 Feb 12:01:51.177 * Discarding previously cached master state.  
    [5956] 20 Feb 12:01:52.333 * Slave asks for synchronization
    [5956] 20 Feb 12:01:52.333 * Full resync requested by slave.
    [5956] 20 Feb 12:01:52.333 * Starting BGSAVE for SYNC
    [5956] 20 Feb 12:01:52.334 * Background saving started by pid 6160
    [6160] 20 Feb 12:01:52.455 * DB saved on disk
    [6160] 20 Feb 12:01:52.456 * RDB: 0 MB of memory used by copy-on-write
    [5956] 20 Feb 12:01:52.526 * Background saving terminated with success
    [5956] 20 Feb 12:01:52.533 * Synchronization with slave succeeded
    
    
    6382 - 93c01f03ad2170a42de960669659edfa24212736
    [5962] 20 Feb 12:01:51.853 * Slave asks for synchronization
    [5962] 20 Feb 12:01:51.853 * Full resync requested by slave.
    [5962] 20 Feb 12:01:51.853 * Starting BGSAVE for SYNC
    [5962] 20 Feb 12:01:51.854 * Background saving started by pid 6158
    [6158] 20 Feb 12:01:52.012 * DB saved on disk
    [6158] 20 Feb 12:01:52.012 * RDB: 0 MB of memory used by copy-on-write
    [5962] 20 Feb 12:01:52.031 * Background saving terminated with success
    [5962] 20 Feb 12:01:52.034 * Synchronization with slave succeeded
    
    
    6383 - 07d70ff010c745fd557335ee41ca34cad9490be2
    
    [13195] 20 Feb 12:01:50.846 # Manual failover requested by slave 90f7f3693753fcd654177128f07a11fc65aeefd2.
    [13195] 20 Feb 12:01:51.178 # Connection with slave 127.0.0.1:6381 lost.
    [13195] 20 Feb 12:01:51.192 # Configuration change detected. Reconfiguring myself as a replica of 90f7f3693753fcd654177128f07a11fc65aeefd2
    [13195] 20 Feb 12:01:51.552 # Migrating to orphaned master 93c01f03ad2170a42de960669659edfa24212736
    [13195] 20 Feb 12:01:51.852 * Connecting to MASTER 127.0.0.1:6382
    [13195] 20 Feb 12:01:51.852 * MASTER <-> SLAVE sync started
    [13195] 20 Feb 12:01:51.852 * Non blocking connect for SYNC fired the event.
    [13195] 20 Feb 12:01:51.852 * Master replied to PING, replication can continue...
    [13195] 20 Feb 12:01:51.853 * Partial resynchronization not possible (no cached master)
    [13195] 20 Feb 12:01:51.853 * Full resync from master: 200fd369f3b51681a57acdef0190e9c3e5edc98c:4116483
    
    6384 - 6ca35fa472366e0c4d8136609ad2f57a14564ac8
    
    [6113] 20 Feb 12:01:51.217 # Configuration change detected. Reconfiguring myself as a replica of 90f7f3693753fcd654177128f07a11fc65aeefd2
    [6113] 20 Feb 12:01:52.333 * Connecting to MASTER 127.0.0.1:6381
    [6113] 20 Feb 12:01:52.333 * MASTER <-> SLAVE sync started
    [6113] 20 Feb 12:01:52.333 * Non blocking connect for SYNC fired the event.
    [6113] 20 Feb 12:01:52.333 * Master replied to PING, replication can continue...
    [6113] 20 Feb 12:01:52.333 * Partial resynchronization not possible (no cached master)
    [6113] 20 Feb 12:01:52.334 * Full resync from master: 8c3c3bf61fbba5ddf2ca0235c1cafcb11936ba22:5581935
    [6113] 20 Feb 12:01:52.527 * MASTER <-> SLAVE sync: receiving 3297810 bytes from master
    [6113] 20 Feb 12:01:52.538 * MASTER <-> SLAVE sync: Flushing old data
    [6113] 20 Feb 12:01:52.552 * MASTER <-> SLAVE sync: Loading DB in memory
    [6113] 20 Feb 12:01:52.590 * MASTER <-> SLAVE sync: Finished with success
    [6113] 20 Feb 12:01:52.591 * Background append only file rewriting started by pid 6161
    [6161] 20 Feb 12:01:52.705 * SYNC append only file rewrite performed
    [6161] 20 Feb 12:01:52.706 * AOF rewrite: 1 MB of memory used by copy-on-write
    [6113] 20 Feb 12:01:52.734 * Background AOF rewrite terminated with success
    [6113] 20 Feb 12:01:52.734 * Parent diff successfully flushed to the rewritten AOF (0 bytes)
    [6113] 20 Feb 12:01:52.734 * Background AOF rewrite finished successfully
    
    6385 - eebe79ad3c9df4c5b991c2315c9e2f91e7f97df7
    No entries between 11:55 and 12:05
    
  13. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Sorry I just tried to emulate your setup but failed since redis-trib complains that there are not at least 3 master nodes. Was your cluster configuration pre-existing? This may be an issue. If you could start from scratch creating a cluster that would be great. This is what I'm doing.

    After starting 6 nodes I'm doing:

    ./redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

    I accept the config, and the result is:

    $ redis-cli -p 7000 cluster nodes
    0321a013eaac15d4237d7d7e6bec62ee1defc44f 127.0.0.1:7002 master - 0 1392896305512 0 connected 10922-16383
    c7fc9189f00355ff6da61064c69753df518f3da1 :0 myself,master - 0 0 0 connected 0-5460
    52f0cf0f1b2bc4bf5f3be36f4d66716e4cf270bf 127.0.0.1:7003 slave c7fc9189f00355ff6da61064c69753df518f3da1 0 1392896303998 0 connected
    a17a282e2b1dc79e6fc98289172418f1d37a8c1e 127.0.0.1:7004 slave 92279d6ff40237f4b33822d40e810abda2dd9ccb 0 1392896304503 0 connected
    92279d6ff40237f4b33822d40e810abda2dd9ccb 127.0.0.1:7001 master - 0 1392896303998 0 connected 5461-10921
    2ca5f7d9d798b8df0b621b8d856101cad0173ccf 127.0.0.1:7005 slave 0321a013eaac15d4237d7d7e6bec62ee1defc44f 0 1392896305009 0 connected
    

    So a master with an additional replica each.

    That is:

    7000 replicated by 7003
    7001 replicated by 7004
    7002 replicated by 7005

    Now I connect with 7005 and write CLUSTER FAILOVER.

    [40368] 20 Feb 12:42:04.014 # Received replication offset for paused master manual failover: 323
    [40368] 20 Feb 12:42:04.031 # All master replication stream processed, manual failover can start.
    [40368] 20 Feb 12:42:04.031 # Start of election delayed for 0 milliseconds (rank #0, offset 323).
    [40368] 20 Feb 12:42:04.133 # Starting a failover election for epoch 1.
    [40368] 20 Feb 12:42:04.141 # Failover election won: I'm the new master.
    [40368] 20 Feb 12:42:04.141 # Connection with master lost.
    [40368] 20 Feb 12:42:04.141 * Caching the disconnected master state.
    [40368] 20 Feb 12:42:04.141 * Discarding previously cached master state.
    [40368] 20 Feb 12:42:04.720 * Slave asks for synchronization
    [40368] 20 Feb 12:42:04.720 * Full resync requested by slave.
    [40368] 20 Feb 12:42:04.720 * Starting BGSAVE for SYNC
    [40368] 20 Feb 12:42:04.720 * Background saving started by pid 40548
    [40548] 20 Feb 12:42:04.721 * DB saved on disk
    [40368] 20 Feb 12:42:04.739 * Background saving terminated with success
    [40368] 20 Feb 12:42:04.739 * Synchronization with slave succeeded
    

    On the other side (7002) I can see:

    [39391] 20 Feb 12:42:03.942 # Manual failover requested by slave 2ca5f7d9d798b8df0b621b8d856101cad0173ccf.
    [39391] 20 Feb 12:42:04.141 # Connection with slave 127.0.0.1:7005 lost.
    [39391] 20 Feb 12:42:04.143 # Configuration change detected. Reconfiguring myself as a replica of 2ca5f7d9d798b8df0b621b8d856101cad0173ccf
    [39391] 20 Feb 12:42:04.719 * Connecting to MASTER 127.0.0.1:7005
    [39391] 20 Feb 12:42:04.719 * MASTER <-> SLAVE sync started
    

    So everything working here.

  14. korpa commented on Feb 20, 2014

    @korpa
    Author

    Ah maybe that is the problem. I created the master with 4 nodes. They all get masters. After that I used cluster replicate xxx on two of these, to make them slaves. So I ended up with just two masters.

  15. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Oh that's interesting, but should not be a problem and should not put the cluster in troubles in theory, if it does, there is an issue. So I guess that you:

    1. created a 4 masters cluster.
    2. Resharded everything to 2 mastres.
    3. and then tried the manual failover.

    Testing.

  16. korpa commented on Feb 20, 2014

    @korpa
    Author

    After that I added the 3rd master with redis-trieb, but did not a re-shared.

    This is the way how this cluster was created.

  17. korpa commented on Feb 20, 2014

    @korpa
    Author

    Ok. Will test after I had lunch.

  18. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Ok the problem is that CLUSTER REPLICATE should be denied if a master has at least one slot assigned, so I'm not sure how it is possible to create the cluster with 4 maters, no reshard, and then using CLUSTER REPLICATE to create a slave. I'm trying :-) have a good lunch and thanks for the help!

  19. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Just tried:

    redis 127.0.0.1:7000> luster replicate b66bb2930c74b50ca49a16f99765d6298af1b174
    (error) ERR To set a master the node must be empty and without assigned slots.
    

    Going to lunch myself, see you later :-)

  20. korpa commented on Feb 20, 2014

    @korpa
    Author

    I think I found the issue. A few days I started to update an old redis cluster which run for nearly half a year. As you switched from 8000 to 16000 shards, it was not possible to easily upgrade the cluster. So I wrote a small script which read every key from the old cluster and added to the new one. While this migration, the old redis-trib still was in the path and not the new one. So I created the new cluster with an very old version of redis-trib. Therefore it was possible to create a cluster with two nodes only.

  21. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Thanks. Still I don't think the lack of master -> slave switch is related to the fact that there were just two masters, there was probably something wrong in the configEpochs of the master. Even if... eventually the master switched to slave, but this should happen as soon as it realizes it is left with 0 slots.

    Please if there is some other issue that you can reproduce or that you noticed, let me know.

    Cheers!

  22. korpa commented on Feb 20, 2014

    @korpa
    Author

    Thank you, too. First of all I will create new cluster with correct version of redis-trib :) then migrate my data the cluster and then play around with the new cluster.

    If I have any issues in the new cluster, I will let you know.

  23. antirez commented on Feb 20, 2014

    @antirez
    Contributor

    Thanks, I'm trying to make migrations simpler. Basically the idea is that if you have a pre-existing cluster, whatever it was shared does not matter, so that you can create N AOF files without keys colliding inside (every key is only in an AOF file), you can just create an empty cluster. Stop N masters and put the N AOF files, restart the masters, run "./redis-trib fix", and the cluster will be fixed to work with the new keys (some keys will be moved however).

    This will be available before beta 2 that is due to 10 March.

    Salvatore

  24. korpa commented on Feb 20, 2014

    @korpa
    Author

    Sounds great. Really looking forward to it. Will test it, as soon as beta2 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions