Skip to content

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

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

Conversation

wgliang
Copy link
Contributor

@wgliang wgliang commented Dec 4, 2022

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
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

LGTM

@wgliang
Copy link
Contributor Author

wgliang commented Dec 5, 2022

All ready to merge.

@damnever
Copy link
Contributor

damnever commented Dec 6, 2022

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

@friedrichg
Copy link
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

@@ -10,6 +10,7 @@
* [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
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
Copy link
Contributor

damnever commented Dec 6, 2022

@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
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

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
Copy link
Contributor

damnever commented Dec 7, 2022

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
Copy link
Contributor Author

wgliang commented Dec 14, 2022

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