Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process io.EOF but not count #519

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"io"
"math/rand"
"sort"
"sync"
Expand Down Expand Up @@ -403,9 +404,18 @@ func (c *clientStatusMonitor) updateErrorRate(err error) {
// from the SDK client; should not be considered
// as a connection error
var siErr *object.SplitInfoError
if !errors.As(err, &siErr) {
c.incErrorRate()
if errors.As(err, &siErr) {
return
}

// EOF is a critical error, but it makes different sense for different requests and places.
// Each code should process it properly in its own way.
// But it isn't a reason to mark clients as unhealthy.
if errors.Is(err, io.EOF) {
return
}

c.incErrorRate()
}

// clientBuilder is a type alias of client constructors.
Expand Down
6 changes: 6 additions & 0 deletions pool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package pool
import (
"context"
"errors"
"io"
"strconv"
"testing"
"time"
Expand Down Expand Up @@ -543,6 +544,11 @@ func TestHandleError(t *testing.T) {
expectedError: true,
countError: true,
},
{
err: io.EOF,
expectedError: true,
countError: false,
},
} {
t.Run(strconv.Itoa(i), func(t *testing.T) {
errCount := monitor.currentErrorRate()
Expand Down
Loading