Skip to content

Commit de69b49

Browse files
author
Bhargav Dodla
committed
fix: Fixed issue with context cancelled error leading to connection spikes on Master
1 parent e63669e commit de69b49

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
@@ -1344,7 +1344,9 @@ func (c *ClusterClient) processPipelineNode(
13441344
_ = node.Client.withProcessPipelineHook(ctx, cmds, func(ctx context.Context, cmds []Cmder) error {
13451345
cn, err := node.Client.getConn(ctx)
13461346
if err != nil {
1347-
node.MarkAsFailing()
1347+
if !isContextError(err) {
1348+
node.MarkAsFailing()
1349+
}
13481350
_ = c.mapCmdsByNode(ctx, failedCmds, cmds)
13491351
setCmdsErr(cmds, err)
13501352
return err

0 commit comments

Comments
 (0)