Skip to content

Commit

Permalink
Increase read timeout for blocking commands and don't retry such comm…
Browse files Browse the repository at this point in the history
…ands
  • Loading branch information
vmihailenco committed Sep 29, 2017
1 parent 34ce349 commit 7cb146a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions internal/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
8 changes: 4 additions & 4 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7cb146a

Please sign in to comment.