From cc95230ae5e95e2e2fed5be830850c1f8d641c95 Mon Sep 17 00:00:00 2001 From: Slava Markeyev Date: Mon, 6 May 2024 18:23:32 -0700 Subject: [PATCH] fix handling replica info result --- rediscluster/slotrange.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/rediscluster/slotrange.go b/rediscluster/slotrange.go index d8a0c1b..33955e0 100644 --- a/rediscluster/slotrange.go +++ b/rediscluster/slotrange.go @@ -215,11 +215,22 @@ func (s *shard) setReplicaInfo(res interface{}, n uint64) { } else if n&1 == 0 { str, ok := res.(string) haserr = !(ok && str == "OK") - } else if buf, ok := res.([]byte); !ok { + } + + var buf []byte + switch v := res.(type) { + case []byte: + buf = v + case redis.ByteResponse: + buf = v.Val + default: haserr = true - } else if bytes.Contains(buf, []byte("master_link_status:down")) || bytes.Contains(buf, []byte("loading:1")) { + } + + if bytes.Contains(buf, []byte("master_link_status:down")) || bytes.Contains(buf, []byte("loading:1")) { haserr = true } + for { oldstate := atomic.LoadUint32(&s.good) newstate := oldstate