Skip to content

Commit 50058e2

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

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Go
22

33
on:
44
push:
5-
branches: [master, v9, v9.7]
5+
branches: [master, v9]
66
pull_request:
7-
branches: [master, v9, v9.7]
7+
branches: [master, v9]
88

99
permissions:
1010
contents: read

error.go

Lines changed: 9 additions & 0 deletions
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

Lines changed: 3 additions & 1 deletion
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)