mirror of https://github.com/go-redis/redis.git
Merge pull request #648 from go-redis/fix/cmd-timeout
Increase read timeout for blocking commands and don't retry such commands
This commit is contained in:
commit
8e6b51ec3a
|
@ -656,7 +656,7 @@ func (c *ClusterClient) Process(cmd Cmder) error {
|
|||
continue
|
||||
}
|
||||
|
||||
if internal.IsRetryableError(err) {
|
||||
if internal.IsRetryableError(err, true) {
|
||||
var nodeErr error
|
||||
node, nodeErr = c.nodes.Random()
|
||||
if nodeErr != nil {
|
||||
|
|
|
@ -11,7 +11,7 @@ func readTimeout(timeout time.Duration) time.Duration {
|
|||
if timeout == 0 {
|
||||
return 0
|
||||
}
|
||||
return timeout + time.Second
|
||||
return timeout + 10*time.Second
|
||||
}
|
||||
|
||||
func usePrecise(dur time.Duration) bool {
|
||||
|
|
|
@ -12,9 +12,9 @@ type RedisError string
|
|||
|
||||
func (e RedisError) Error() string { return string(e) }
|
||||
|
||||
func IsRetryableError(err error) bool {
|
||||
func IsRetryableError(err error, retryNetError bool) bool {
|
||||
if IsNetworkError(err) {
|
||||
return true
|
||||
return retryNetError
|
||||
}
|
||||
s := err.Error()
|
||||
if s == "ERR max number of clients reached" {
|
||||
|
|
8
redis.go
8
redis.go
|
@ -136,7 +136,7 @@ func (c *baseClient) defaultProcess(cmd Cmder) error {
|
|||
cn, _, err := c.getConn()
|
||||
if err != nil {
|
||||
cmd.setErr(err)
|
||||
if internal.IsRetryableError(err) {
|
||||
if internal.IsRetryableError(err, true) {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
|
@ -146,7 +146,7 @@ func (c *baseClient) defaultProcess(cmd Cmder) error {
|
|||
if err := writeCmd(cn, cmd); err != nil {
|
||||
c.releaseConn(cn, err)
|
||||
cmd.setErr(err)
|
||||
if internal.IsRetryableError(err) {
|
||||
if internal.IsRetryableError(err, true) {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
|
@ -155,7 +155,7 @@ func (c *baseClient) defaultProcess(cmd Cmder) error {
|
|||
cn.SetReadTimeout(c.cmdTimeout(cmd))
|
||||
err = cmd.readReply(cn)
|
||||
c.releaseConn(cn, err)
|
||||
if err != nil && internal.IsRetryableError(err) {
|
||||
if err != nil && internal.IsRetryableError(err, cmd.readTimeout() == nil) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ func (c *baseClient) pipelineExecer(p pipelineProcessor) pipelineExecer {
|
|||
}
|
||||
_ = c.connPool.Remove(cn)
|
||||
|
||||
if !canRetry || !internal.IsRetryableError(err) {
|
||||
if !canRetry || !internal.IsRetryableError(err, true) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue