When I set sentinel config to smth like sentinel monitor mymaster redis-master.somedomain 6379 2 the hostname is replaced by ip address after CONFIG REWRITE performed at sentinel start.

The problem is that the master node sets its own ip address to 127.0.1.1 (it is a known feature/bug on debian-based systems including ubuntu). So when I ask master node for get-master-addr-by-name it tells me 127.0.1.1. Slave nodes return correct master ip obviously.

My suggestion is either to forbid setting hostname in the config file and replace anetResolve() with anetResolveIP() or to place warning somewhere in documentation that setting hostname instead of ip address can lead to confusing results.

The core reason is that getaddrinfo(3) returns the list of all ip addresses associated with this host. And only the host administrator is aware which of them is the valid ip address for external use.

BTW - as said in docs - to update sentinel config at runtime and to start monitoring a new master you can't use an hostname in as ip, but you need to provide an IPv4 or IPv6 address.

Comment From: nlowe

We just got bit by this as well, I think the documentation should be updated to encourage (or even force) people to use the IP of their master instead of hostnames.

Comment From: StephanX

Bitten by this as well, centos7, compiled redis from 3.2.8

Comment From: yossigo

This is addressed by #8282.