The error "Redis Sentinel does not switch master" typically occurs when the Redis Sentinel, which is designed to handle automatic failover and configuration provides high availability for Redis, does not perform its duty of promoting a slave to be a new master when the current master encounters an issue or fails.
There could be a number of reasons for this:
Configuration Issue: The Sentinel system depends heavily on accurate configuration. If the Sentinels are not correctly set up, they may fail to elect a new master.
Network Problems: Redis Sentinels communicate with each other to agree on who the new master should be in case of failure. If there is a network partition or any disruption in communication between sentinels, they might not successfully elect a new master.
Insufficient Number of Sentinels: When fewer than the majority of Sentinels can confirm that the master is down, no failover will occur.
No Suitable Slave: If there's no suitable slave (a slave that is caught up to master), Sentinel won't be able to promote it to the master.
Solution - Here's How To Resolve It
To resolve this issue, you can consider the following steps:
Check Configuration: Ensure that all Redis and Sentinel configurations are correct. This includes making sure that the Sentinels can communicate with each other and with all Redis servers, the 'quorum' parameter is set properly, and the 'down-after-milliseconds' parameter is set accurately.
Test Network Connection: Verify network connectivity between all Sentinel instances. Use tools like ping or telnet to ensure that the Sentinels can reach each other and the Redis servers.
Increase Sentinel Instances: To avoid issues due to a minority of Sentinels being unable to confirm that the master is down, consider increasing the number of Sentinel instances to ensure a consensus can be reached.
Maintain Synchronization of Slaves: Make sure that slaves are properly connected to the master and data is synchronized between them. The 'min-slaves-to-write' and 'min-slaves-max-lag' parameters can help in maintaining robust synchronization.