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:
Vladimir Mihailenco 2017-09-29 16:13:22 +03:00 committed by GitHub
commit 8e6b51ec3a
5 changed files with 9 additions and 9 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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" {

View File

@ -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
}
}

View File

@ -477,7 +477,7 @@ func (c *Ring) pipelineExec(cmds []Cmder) error {
}
_ = shard.Client.connPool.Remove(cn)
if canRetry && internal.IsRetryableError(err) {
if canRetry && internal.IsRetryableError(err, true) {
if failedCmdsMap == nil {
failedCmdsMap = make(map[string][]Cmder)
}