Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refresh cluster topology with CLUSTER SLOTS instead of CLUSTER SHARDS for clusters which version < 8 due to the server bug. #664

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading