As I read the source code of sentinel, I have a small question about the sentinel pub/sub. The question is, the hello message is published to all three kinds of roles: master, replica and sentinel. However, only master and replica has established pub/sub connection. So, is it safe to only publish hello messages to master and replica? Or, is there any other reason I have not figured out?

Comment From: hwware

Hello @Carmon-Lee , the main design purpose for the pub/sub connection is making different sentinels discover each other and sharing information. It is not designed to sending information to masters/replicas but for the other monitoring sentinels. For example, different sentinels may monitor same master/replica and by subscribing/publishing hello message in the __sentinel__:hello channel. sentinel is able to discover each other. This is important when sentinel doing failover process leader election step, since majority of sentinels need to make "agreements" selecting the leader. Also when sentinel updated the master configration, eg. after the failover is done and master was switched, this is a way to notify other sentinels master has been switched, thanks!

Comment From: Carmon-Lee

Yeah, I know what you said here. My question here is, can we just publish to the topic sentinel:hello of master and replica? I can't see the necessity of publishing to the topic of other sentinel, since we just subscribe the topic of master and replica?

Comment From: hwware

@Carmon-Lee , publishing to sentinel hello message is still necessary, please note the way sentinel process the PUBLISH command is very different than the Redis Server mode, it will receive/process the hello message from other sentinel(even if the master Pub/Sub link is down.) This is useful for example, if master was down, sentinel can still talk and share information through the Pub/Sub link. Please take look https://github.com/redis/redis/blob/unstable/src/sentinel.c#L4137 and line 4148 , you should understand more about this behaviour. thanks

Comment From: Carmon-Lee

@hwware , thanks for your careful explaining, I finally noticed the sentinel implementation of the command "publish", it's really necessary for the sentinel to publish to other sentinels