Remove releaseConnStrict

This commit is contained in:
Vladimir Mihailenco 2019-08-08 10:43:10 +03:00
parent 2927e15b6b
commit 48224a399f
4 changed files with 8 additions and 19 deletions

View File

@ -1075,7 +1075,7 @@ func (c *ClusterClient) _processPipeline(ctx context.Context, cmds []Cmder) erro
} }
err = c.pipelineProcessCmds(ctx, node, cn, cmds, failedCmds) err = c.pipelineProcessCmds(ctx, node, cn, cmds, failedCmds)
node.Client.releaseConnStrict(cn, err) node.Client.releaseConn(cn, err)
}(node, cmds) }(node, cmds)
} }
@ -1282,7 +1282,7 @@ func (c *ClusterClient) _processTxPipeline(ctx context.Context, cmds []Cmder) er
} }
err = c.txPipelineProcessCmds(ctx, node, cn, cmds, failedCmds) err = c.txPipelineProcessCmds(ctx, node, cn, cmds, failedCmds)
node.Client.releaseConnStrict(cn, err) node.Client.releaseConn(cn, err)
}(node, cmds) }(node, cmds)
} }

View File

@ -45,12 +45,13 @@ func isRedisError(err error) bool {
} }
func isBadConn(err error, allowTimeout bool) bool { func isBadConn(err error, allowTimeout bool) bool {
switch err { if err == nil {
case nil:
return false return false
} }
if isRedisError(err) { if isRedisError(err) {
return isReadOnlyError(err) // #790 // Close connections in read only state in case domain addr is used
// and domain resolves to a different Redis Server. See #790.
return isReadOnlyError(err)
} }
if allowTimeout { if allowTimeout {
if netErr, ok := err.(net.Error); ok && netErr.Timeout() { if netErr, ok := err.(net.Error); ok && netErr.Timeout() {

View File

@ -235,18 +235,6 @@ func (c *baseClient) releaseConn(cn *pool.Conn, err error) {
} }
} }
func (c *baseClient) releaseConnStrict(cn *pool.Conn, err error) {
if c.limiter != nil {
c.limiter.ReportResult(err)
}
if err == nil || isRedisError(err) {
c.connPool.Put(cn)
} else {
c.connPool.Remove(cn, err)
}
}
func (c *baseClient) process(ctx context.Context, cmd Cmder) error { func (c *baseClient) process(ctx context.Context, cmd Cmder) error {
for attempt := 0; attempt <= c.opt.MaxRetries; attempt++ { for attempt := 0; attempt <= c.opt.MaxRetries; attempt++ {
if attempt > 0 { if attempt > 0 {
@ -351,7 +339,7 @@ func (c *baseClient) generalProcessPipeline(
} }
canRetry, err := p(ctx, cn, cmds) canRetry, err := p(ctx, cn, cmds)
c.releaseConnStrict(cn, err) c.releaseConn(cn, err)
if !canRetry || !isRetryableError(err, true) { if !canRetry || !isRetryableError(err, true) {
break break

View File

@ -660,7 +660,7 @@ func (c *Ring) generalProcessPipeline(
} else { } else {
canRetry, err = shard.Client.pipelineProcessCmds(ctx, cn, cmds) canRetry, err = shard.Client.pipelineProcessCmds(ctx, cn, cmds)
} }
shard.Client.releaseConnStrict(cn, err) shard.Client.releaseConn(cn, err)
if canRetry && isRetryableError(err, true) { if canRetry && isRetryableError(err, true) {
mu.Lock() mu.Lock()