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

Store: If request ctx has an error we do not increment opsFailures counter #3179

Merged
merged 3 commits into from
Sep 21, 2020
Merged
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions pkg/objstore/objstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func (b *metricBucket) Attributes(ctx context.Context, name string) (ObjectAttri
start := time.Now()
attrs, err := b.bkt.Attributes(ctx, name)
if err != nil {
if !b.isOpFailureExpected(err) {
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
b.opsFailures.WithLabelValues(op).Inc()
}
return attrs, err
Expand All @@ -340,7 +340,7 @@ func (b *metricBucket) Get(ctx context.Context, name string) (io.ReadCloser, err

rc, err := b.bkt.Get(ctx, name)
if err != nil {
if !b.isOpFailureExpected(err) {
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
b.opsFailures.WithLabelValues(op).Inc()
}
return nil, err
Expand All @@ -360,7 +360,7 @@ func (b *metricBucket) GetRange(ctx context.Context, name string, off, length in

rc, err := b.bkt.GetRange(ctx, name, off, length)
if err != nil {
if !b.isOpFailureExpected(err) {
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
b.opsFailures.WithLabelValues(op).Inc()
}
return nil, err
Expand All @@ -381,7 +381,7 @@ func (b *metricBucket) Exists(ctx context.Context, name string) (bool, error) {
start := time.Now()
ok, err := b.bkt.Exists(ctx, name)
if err != nil {
if !b.isOpFailureExpected(err) {
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
b.opsFailures.WithLabelValues(op).Inc()
}
return false, err
Expand All @@ -396,7 +396,7 @@ func (b *metricBucket) Upload(ctx context.Context, name string, r io.Reader) err

start := time.Now()
if err := b.bkt.Upload(ctx, name, r); err != nil {
if !b.isOpFailureExpected(err) {
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
b.opsFailures.WithLabelValues(op).Inc()
}
return err
Expand All @@ -412,7 +412,7 @@ func (b *metricBucket) Delete(ctx context.Context, name string) error {

start := time.Now()
if err := b.bkt.Delete(ctx, name); err != nil {
if !b.isOpFailureExpected(err) {
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if !b.isOpFailureExpected(err) && ctx.Err() == nil {
if !b.isOpFailureExpected(err) && ctx.Err() != context.Canceled {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree timeouts are legit failures, but this comment apply to any place, not just here, right? Also, is there a good reason why we don't we the context.Canceled check isOpFailureExpected()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I have observed, cancelled requests can cause timeouts:
Screen Shot 2020-09-10 at 10 43 58 AM

If you notice, query cancels the request but store reports it as aborted. In my opinion that should be reported as cancelled, and not increase the error count.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or does Aborted != timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree timeouts are legit failures, but this comment apply to any place, not just here, right? Also, is there a good reason why we don't we the context.Canceled check isOpFailureExpected()?

If that is a better place for this then I have no problems making the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isOpFailureExpected is really only for user specified function what to expect. I believe Cancel is valid to be ignored no matter what user specifies, no? (:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right @bwplotka 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the PR to use that context.

b.opsFailures.WithLabelValues(op).Inc()
}
return err
Expand Down