Skip to content

Commit 7c445ab

Browse files
author
Bhargav Dodla
committed
fix: Fixed issue with context cancelled error leading to connection spikes on Master
1 parent 930d904 commit 7c445ab

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

error.go

+9
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ type Error interface {
3838

3939
var _ Error = proto.RedisError("")
4040

41+
func isContextError(err error) bool {
42+
switch err {
43+
case context.Canceled, context.DeadlineExceeded:
44+
return true
45+
default:
46+
return false
47+
}
48+
}
49+
4150
func shouldRetry(err error, retryTimeout bool) bool {
4251
switch err {
4352
case io.EOF, io.ErrUnexpectedEOF:

osscluster.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,9 @@ func (c *ClusterClient) processPipelineNode(
13211321
_ = node.Client.withProcessPipelineHook(ctx, cmds, func(ctx context.Context, cmds []Cmder) error {
13221322
cn, err := node.Client.getConn(ctx)
13231323
if err != nil {
1324-
node.MarkAsFailing()
1324+
if !isContextError(err) {
1325+
node.MarkAsFailing()
1326+
}
13251327
_ = c.mapCmdsByNode(ctx, failedCmds, cmds)
13261328
setCmdsErr(cmds, err)
13271329
return err

0 commit comments

Comments
 (0)