forked from mirror/redis
Retry cluster down errors
This commit is contained in:
parent
a9364f117c
commit
63e3bc58c7
|
@ -583,7 +583,7 @@ func (c *ClusterClient) Process(cmd Cmder) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// On network errors try random node.
|
// On network errors try random node.
|
||||||
if internal.IsRetryableError(err) {
|
if internal.IsRetryableError(err) || internal.IsClusterDownError(err) {
|
||||||
node, err = c.nodes.Random()
|
node, err = c.nodes.Random()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cmd.setErr(err)
|
cmd.setErr(err)
|
||||||
|
|
|
@ -700,14 +700,14 @@ var _ = Describe("ClusterClient timeout", func() {
|
||||||
testTimeout()
|
testTimeout()
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("network timeout", func() {
|
Context("ClientPause timeout", func() {
|
||||||
const pause = time.Second
|
const pause = time.Second
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
opt := redisClusterOptions()
|
opt := redisClusterOptions()
|
||||||
opt.ReadTimeout = 100 * time.Millisecond
|
opt.ReadTimeout = pause / 10
|
||||||
opt.WriteTimeout = 100 * time.Millisecond
|
opt.WriteTimeout = pause / 10
|
||||||
opt.MaxRedirects = 1
|
opt.MaxRedirects = -1
|
||||||
client = cluster.clusterClient(opt)
|
client = cluster.clusterClient(opt)
|
||||||
|
|
||||||
err := client.ForEachNode(func(client *redis.Client) error {
|
err := client.ForEachNode(func(client *redis.Client) error {
|
||||||
|
|
|
@ -67,9 +67,9 @@ func IsMovedError(err error) (moved bool, ask bool, addr string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsLoadingError(err error) bool {
|
func IsLoadingError(err error) bool {
|
||||||
return strings.HasPrefix(err.Error(), "LOADING")
|
return strings.HasPrefix(err.Error(), "LOADING ")
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsExecAbortError(err error) bool {
|
func IsClusterDownError(err error) bool {
|
||||||
return strings.HasPrefix(err.Error(), "EXECABORT")
|
return strings.HasPrefix(err.Error(), "CLUSTERDOWN ")
|
||||||
}
|
}
|
Loading…
Reference in New Issue