• Moti Cohen's avatar
    Fix sentinel function that compares hostnames (if failed resolve) (#11419) · 042512aa
    Moti Cohen authored
    Funcion sentinelAddrEqualsHostname() of sentinel makes DNS resolve
    and based on it determines if two IP addresses are equal. Now, If the
    DNS resolve command fails, the function simply returns 0, even if the
    hostnames are identical.
    
    This might become an issue in case of failover such that sentinel might
    receives from Redis instance, response to regular INFO query it sent,
    and wrongly decide that the instance is pointing to is different leader
    than the one recorded because of this function, yet hostnames are
    identical. In turn sentinel disconnects the connection between sentinel
    and valid slave which leads to -failover-abort-no-good-slave.
    See issue #11241.
    
    I managed to reproduce only part of the flow in which the function
    return wrong result and trigger +fix-slave-config.
    
    The fix is even if the function failed to resolve then compare based on
    hostnames. That is our best effort as long as the server is unavailable
    for some reason. It is fine since Redis instance cannot have multiple
    hostnames for a given setup
    
    (cherry picked from commit bd23b15a)
    042512aa
sentinel.c 200 KB