Skip to content

Commit

Permalink
fix: refresh cluster topology with CLUSTER SLOTS instead of `CLUSTE…
Browse files Browse the repository at this point in the history
…R SHARDS` for clusters which version < 8 due to the server bug. (#664)

Signed-off-by: Rueian <[email protected]>
  • Loading branch information
rueian authored Nov 7, 2024
1 parent bf8de44 commit ff7e544
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ type clusterslots struct {
}

func (s clusterslots) parse(tls bool) map[string]group {
if s.ver < 7 {
if s.ver < 8 {
return parseSlots(s.reply.val, s.addr)
}
return parseShards(s.reply.val, s.addr, tls)
Expand All @@ -147,7 +147,7 @@ func getClusterSlots(c conn, timeout time.Duration) clusterslots {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
v := c.Version()
if v < 7 {
if v < 8 {
return clusterslots{reply: c.Do(ctx, cmds.SlotCmd), addr: c.Addr(), ver: v}
}
return clusterslots{reply: c.Do(ctx, cmds.ShardsCmd), addr: c.Addr(), ver: v}
Expand Down
10 changes: 5 additions & 5 deletions cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ func TestClusterClientInit(t *testing.T) {
}
return shardsResp
},
VersionFn: func() int { return 7 },
VersionFn: func() int { return 8 },
}
},
newRetryer(defaultRetryDelayFn),
Expand Down Expand Up @@ -816,7 +816,7 @@ func TestClusterClientInit(t *testing.T) {
DoFn: func(cmd Completed) RedisResult {
return newResult(RedisMessage{typ: '*', values: []RedisMessage{}}, nil)
},
VersionFn: func() int { return 7 },
VersionFn: func() int { return 8 },
}
},
newRetryer(defaultRetryDelayFn),
Expand Down Expand Up @@ -859,7 +859,7 @@ func TestClusterClientInit(t *testing.T) {
})

t.Run("shards", func(t *testing.T) {
client, err := getClient(7)
client, err := getClient(8)
if err != nil {
t.Fatalf("unexpected err %v", err)
}
Expand Down Expand Up @@ -933,7 +933,7 @@ func TestClusterClientInit(t *testing.T) {
}
return shardsResp
},
VersionFn: func() int { return 7 },
VersionFn: func() int { return 8 },
}
},
newRetryer(defaultRetryDelayFn),
Expand All @@ -953,7 +953,7 @@ func TestClusterClientInit(t *testing.T) {
DoFn: func(cmd Completed) RedisResult {
return shardsRespTls
},
VersionFn: func() int { return 7 },
VersionFn: func() int { return 8 },
}
},
newRetryer(defaultRetryDelayFn),
Expand Down

0 comments on commit ff7e544

Please sign in to comment.