Retry cluster down errors

This commit is contained in:
Vladimir Mihailenco 2017-08-15 10:12:43 +03:00
parent a9364f117c
commit 63e3bc58c7
3 changed files with 8 additions and 8 deletions

View File

@ -583,7 +583,7 @@ func (c *ClusterClient) Process(cmd Cmder) error {
}
// On network errors try random node.
if internal.IsRetryableError(err) {
if internal.IsRetryableError(err) || internal.IsClusterDownError(err) {
node, err = c.nodes.Random()
if err != nil {
cmd.setErr(err)

View File

@ -700,14 +700,14 @@ var _ = Describe("ClusterClient timeout", func() {
testTimeout()
})
Context("network timeout", func() {
Context("ClientPause timeout", func() {
const pause = time.Second
BeforeEach(func() {
opt := redisClusterOptions()
opt.ReadTimeout = 100 * time.Millisecond
opt.WriteTimeout = 100 * time.Millisecond
opt.MaxRedirects = 1
opt.ReadTimeout = pause / 10
opt.WriteTimeout = pause / 10
opt.MaxRedirects = -1
client = cluster.clusterClient(opt)
err := client.ForEachNode(func(client *redis.Client) error {

View File

@ -70,6 +70,6 @@ func IsLoadingError(err error) bool {
return strings.HasPrefix(err.Error(), "LOADING ")
}
func IsExecAbortError(err error) bool {
return strings.HasPrefix(err.Error(), "EXECABORT")
func IsClusterDownError(err error) bool {
return strings.HasPrefix(err.Error(), "CLUSTERDOWN ")
}