Skip to content

Commit

Permalink
fix: Fixed issue with context cancelled error leading to connection s…
Browse files Browse the repository at this point in the history
…pikes on Master
  • Loading branch information
Bhargav Dodla committed Nov 15, 2024
1 parent 6866752 commit 50058e2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Go

on:
push:
branches: [master, v9, v9.7]
branches: [master, v9]
pull_request:
branches: [master, v9, v9.7]
branches: [master, v9]

permissions:
contents: read
Expand Down
9 changes: 9 additions & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ type Error interface {

var _ Error = proto.RedisError("")

func isContextError(err error) bool {
switch err {
case context.Canceled, context.DeadlineExceeded:
return true
default:
return false
}
}

func shouldRetry(err error, retryTimeout bool) bool {
switch err {
case io.EOF, io.ErrUnexpectedEOF:
Expand Down
4 changes: 3 additions & 1 deletion osscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,9 @@ func (c *ClusterClient) processPipelineNode(
_ = node.Client.withProcessPipelineHook(ctx, cmds, func(ctx context.Context, cmds []Cmder) error {
cn, err := node.Client.getConn(ctx)
if err != nil {
node.MarkAsFailing()
if !isContextError(err) {
node.MarkAsFailing()
}
_ = c.mapCmdsByNode(ctx, failedCmds, cmds)
setCmdsErr(cmds, err)
return err
Expand Down

0 comments on commit 50058e2

Please sign in to comment.