Describe the bug Redis Sentinel unable to place resurrected master as slave in the master-slave setup once previous/former master node comes back online. It is working only when one of the sentinel node is manually restarted or if the setup is based on static IP Address which would then place the resurrected master node under new Master-slave Setup.

A short description of the bug.

Redis Sentinel is configured based on hostnames as we have not preferred to go for static IP address since it is a containerized environment. Redisson Client is used as java client for setting up Master Slave Setup with sentinels for failover.

Brief Description of Setup 1. 1- Master Node 2-Slave Nodes 3 -Sentinel nodes configuration setup in docker-compose file 2. redis-version 6.2.6 (latest)

To reproduce

Steps to reproduce the behavior and/or a minimal code sample.

Sentinel-conf inside docker-compose.yml The same config is reused for other 2 sentinels redis-sentinel-1: image: redis container_name: redis-sentinel-1 command: > bash -c "echo 'port 26380' > sentinel.conf && echo 'dir /tmp' >> sentinel.conf && echo 'sentinel resolve-hostnames yes' >> sentinel.conf && echo 'sentinel monitor mymaster master 6378 2' >> sentinel.conf && echo 'sentinel down-after-milliseconds mymaster 100' >> sentinel.conf && echo 'sentinel failover-timeout mymaster 200' >> sentinel.conf && echo 'protected-mode no' >> sentinel.conf && cat sentinel.conf && redis-server sentinel.conf --sentinel" ports: - 26380:26380

Redis Nodes setup (1 master and 2 slave nodes)

master: hostname: mymaster container_name: master image: redis environment: - ALLOW_EMPTY_PASSWORD=yes ports: - 6378:6378 restart: "no" command: [ "redis-server", "--bind", "master", "--port", "6378"]

slave-a: container_name: slave-a image: redis environment: - ALLOW_EMPTY_PASSWORD=yes ports: - 7000:7000 command: [ "redis-server", "--bind", "slave-a", "--port", "7000", "--replicaof", "master", "6378"]

slave-b: container_name: slave-b image: redis environment: - ALLOW_EMPTY_PASSWORD=yes ports: - 7001:7001 command: [ "redis-server", "--bind", "slave-b", "--port", "7001", "--replicaof", "master", "6378"]

Java code configuration

@Bean @Qualifier("redissonSentinelClient") public RedissonClient redissonSentinelClient() { Config config = new Config(); List sentinelAddresses = new ArrayList<>(); nodes.forEach(node->sentinelAddresses.add(redisUrl+node)); System.out.println("The Sentinel Address are : " + sentinelAddresses); config.setCodec(new JsonJacksonCodec()); config.useSentinelServers() .setMasterName(master) .setSentinelAddresses(sentinelAddresses); System.out.println("The Sentinel Address are : " + config.useSentinelServers().getSentinelAddresses()); System.out.println("The Sentinel Master name is : " + config.useSentinelServers().getMasterName()); this.redissonClient = Redisson.create(config); return redissonClient; }

application.yml file

spring: redis: port: 6378 url: "redis://" host: redis sentinel: master: mymaster nodes: redis-sentinel-1:26380,redis-sentinel-2:26380,redis-sentinel-3:26380

redis: master: host: master port: 6378 slaves: - host: slave-a port: 7000 - host: slave-b port: 7001

Expected behavior

Redis Sentinel should work flawlessly during failover as well as should be able to place the resurrected master under new Master once old master is back online or resurrected.

A description of what you expected to happen.

Additional information

Any additional information that is relevant to the problem.

Tried with IP address settings instead of hostnames working flawlessly and the configurations are updated in timely manner. I checked the logs in docker desktop so "convert-to-slave" configuration is not being set with hostname configuration unless one of the sentinel is restarted

Comment From: varunbh79

can anyone please look into the issue and let me know if any additional details I need to provide

Regards Varun