Increase read timeout for blocking commands and don't retry such commands

This commit is contained in:
Vladimir Mihailenco 2017-09-27 10:58:06 +03:00
parent 34ce349cb7
commit 7cb146a31b
5 changed files with 9 additions and 9 deletions

View File

@ -656,7 +656,7 @@ func (c *ClusterClient) Process(cmd Cmder) error {
continue continue
} }
if internal.IsRetryableError(err) { if internal.IsRetryableError(err, true) {
var nodeErr error var nodeErr error
node, nodeErr = c.nodes.Random() node, nodeErr = c.nodes.Random()
if nodeErr != nil { if nodeErr != nil {

View File

@ -11,7 +11,7 @@ func readTimeout(timeout time.Duration) time.Duration {
if timeout == 0 { if timeout == 0 {
return 0 return 0
} }
return timeout + time.Second return timeout + 10*time.Second
} }
func usePrecise(dur time.Duration) bool { func usePrecise(dur time.Duration) bool {

View File

@ -12,9 +12,9 @@ type RedisError string
func (e RedisError) Error() string { return string(e) } func (e RedisError) Error() string { return string(e) }
func IsRetryableError(err error) bool { func IsRetryableError(err error, retryNetError bool) bool {
if IsNetworkError(err) { if IsNetworkError(err) {
return true return retryNetError
} }
s := err.Error() s := err.Error()
if s == "ERR max number of clients reached" { 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() cn, _, err := c.getConn()
if err != nil { if err != nil {
cmd.setErr(err) cmd.setErr(err)
if internal.IsRetryableError(err) { if internal.IsRetryableError(err, true) {
continue continue
} }
return err return err
@ -146,7 +146,7 @@ func (c *baseClient) defaultProcess(cmd Cmder) error {
if err := writeCmd(cn, cmd); err != nil { if err := writeCmd(cn, cmd); err != nil {
c.releaseConn(cn, err) c.releaseConn(cn, err)
cmd.setErr(err) cmd.setErr(err)
if internal.IsRetryableError(err) { if internal.IsRetryableError(err, true) {
continue continue
} }
return err return err
@ -155,7 +155,7 @@ func (c *baseClient) defaultProcess(cmd Cmder) error {
cn.SetReadTimeout(c.cmdTimeout(cmd)) cn.SetReadTimeout(c.cmdTimeout(cmd))
err = cmd.readReply(cn) err = cmd.readReply(cn)
c.releaseConn(cn, err) c.releaseConn(cn, err)
if err != nil && internal.IsRetryableError(err) { if err != nil && internal.IsRetryableError(err, cmd.readTimeout() == nil) {
continue continue
} }
@ -221,7 +221,7 @@ func (c *baseClient) pipelineExecer(p pipelineProcessor) pipelineExecer {
} }
_ = c.connPool.Remove(cn) _ = c.connPool.Remove(cn)
if !canRetry || !internal.IsRetryableError(err) { if !canRetry || !internal.IsRetryableError(err, true) {
break break
} }
} }

View File

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