Skip to content

Commit

Permalink
Remove releaseConnStrict
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Aug 8, 2019
1 parent 2927e15 commit 48224a3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
4 changes: 2 additions & 2 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ func (c *ClusterClient) _processPipeline(ctx context.Context, cmds []Cmder) erro
}

err = c.pipelineProcessCmds(ctx, node, cn, cmds, failedCmds)
node.Client.releaseConnStrict(cn, err)
node.Client.releaseConn(cn, err)
}(node, cmds)
}

Expand Down Expand Up @@ -1282,7 +1282,7 @@ func (c *ClusterClient) _processTxPipeline(ctx context.Context, cmds []Cmder) er
}

err = c.txPipelineProcessCmds(ctx, node, cn, cmds, failedCmds)
node.Client.releaseConnStrict(cn, err)
node.Client.releaseConn(cn, err)
}(node, cmds)
}

Expand Down
7 changes: 4 additions & 3 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ func isRedisError(err error) bool {
}

func isBadConn(err error, allowTimeout bool) bool {
switch err {
case nil:
if err == nil {
return false
}
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 netErr, ok := err.(net.Error); ok && netErr.Timeout() {
Expand Down
14 changes: 1 addition & 13 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
for attempt := 0; attempt <= c.opt.MaxRetries; attempt++ {
if attempt > 0 {
Expand Down Expand Up @@ -351,7 +339,7 @@ func (c *baseClient) generalProcessPipeline(
}

canRetry, err := p(ctx, cn, cmds)
c.releaseConnStrict(cn, err)
c.releaseConn(cn, err)

if !canRetry || !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 @@ -660,7 +660,7 @@ func (c *Ring) generalProcessPipeline(
} else {
canRetry, err = shard.Client.pipelineProcessCmds(ctx, cn, cmds)
}
shard.Client.releaseConnStrict(cn, err)
shard.Client.releaseConn(cn, err)

if canRetry && isRetryableError(err, true) {
mu.Lock()
Expand Down

0 comments on commit 48224a3

Please sign in to comment.