Skip to content

Fix canceled distributor push requests as 499 instead of 500#5018

Closed
wgliang wants to merge 1 commit into
cortexproject:masterfrom
wgliang:enhancement/canceled-distributor-requests-as-499
Closed

Fix canceled distributor push requests as 499 instead of 500#5018
wgliang wants to merge 1 commit into
cortexproject:masterfrom
wgliang:enhancement/canceled-distributor-requests-as-499

Conversation

@wgliang

@wgliang wgliang commented Dec 4, 2022

Copy link
Copy Markdown
Contributor

Signed-off-by: wangguoliang iamwgliang@gmail.com

What this PR does:
FIx canceled distributor push requests as 499 instead of 500.

FYI:https://www.webfx.com/web-development/glossary/http-status-codes/

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@wgliang wgliang changed the title FIx canceled distributor push requests as 499 instead of 500 Fix canceled distributor push requests as 499 instead of 500 Dec 4, 2022
@wgliang
wgliang force-pushed the enhancement/canceled-distributor-requests-as-499 branch from 08433eb to 9581811 Compare December 4, 2022 08:42

@yeya24 yeya24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@wgliang

wgliang commented Dec 5, 2022

Copy link
Copy Markdown
Contributor Author

All ready to merge.

@damnever

damnever commented Dec 6, 2022

Copy link
Copy Markdown
Contributor

This change may cause users to lose data since Prometheus(agent) does not retry on 499.

@friedrichg

Copy link
Copy Markdown
Member

@damnever The 499 is never returned to grafana agent. The user canceled the request so they won't get the reply.
This is similar to #2156

Comment thread CHANGELOG.md
* [FEATURE] Ingester: Added `-blocks-storage.tsdb.head-chunks-write-queue-size` allowing to configure the size of the in-memory queue used before flushing chunks to the disk . #5000
* [FEATURE] Query Frontend: Log query params in query frontend even if error happens. #5005
* [BUGFIX] Updated `golang.org/x/net` dependency to fix CVE-2022-27664. #5008
* [BUGFIX] Fix canceled distributor push requests as 499 instead of 500. #5018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I bet many users are going to understand this line as clients will receive 499. Can you make it obvious that this only affects internal metrics and logs?

@damnever

damnever commented Dec 6, 2022

Copy link
Copy Markdown
Contributor

@friedrichg IMHO, context could be canceled by the distributor level timeout(-distributor.remote-timeout), so the clients may still receive the 499 response.

@friedrichg

Copy link
Copy Markdown
Member

@damnever you are absolutely right. We should continue to return 500 if the remote-timeout is hit. This PR should ensure that. Good catch

Comment thread pkg/util/push/push.go
Signed-off-by: wangguoliang <iamwgliang@gmail.com>
@wgliang
wgliang force-pushed the enhancement/canceled-distributor-requests-as-499 branch from 9581811 to 254ccd2 Compare December 6, 2022 13:28
@damnever

damnever commented Dec 7, 2022

Copy link
Copy Markdown
Contributor

The context.Canceled isn’t always triggered by the root context, the cause could be any context inside the push, there are dependencies, and so on. We need to distinguish the difference. When the context.Canceled is returned in the middle of pushing data to ingesters (maybe this one?), then we may lose data since the Prometheus agent doesn’t retry on 499.

@wgliang

wgliang commented Dec 14, 2022

Copy link
Copy Markdown
Contributor Author

I will close this PR and re-issue a fix if there is a better solution. Thank you for your feedback. @damnever @friedrichg

@wgliang wgliang closed this Dec 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants