From aa740eed3e7be8dafc7adcb07910963c357f5787 Mon Sep 17 00:00:00 2001 From: kwen <38367518+kwenzh@users.noreply.github.com> Date: Thu, 17 Apr 2025 19:30:59 +0800 Subject: [PATCH] Add check to the master address has been obtained Before closing the done channel, add a check to see if the master address has been obtained. If the master address has been obtained, then proceed with the subsequent operations. --- sentinel.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sentinel.go b/sentinel.go index 063866353..77beb7b86 100644 --- a/sentinel.go +++ b/sentinel.go @@ -618,6 +618,9 @@ func (c *sentinelFailover) MasterAddr(ctx context.Context) (string, error) { } return "", errors.New("redis: all sentinels specified in configuration are unreachable") case err := <-errCh: + if masterAddr != "" { + return masterAddr, nil + } return "", err } }