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

Prevent failed ingestion from affecting rate limiting in distributor. #3825

Merged
merged 6 commits into from
Feb 17, 2021

Conversation

stevesg
Copy link
Contributor

@stevesg stevesg commented Feb 15, 2021

What this PR does:
Change the handling of the rate limiting in the distributor such that when the ingestion fails, the reservation in the rate limiter is canceled, returning the tokens for future use in the proceeding requests.

In the process, a change was made to the util/limiter package to use ReserveN. To match the semantics of ApplyN, we have to check the Delay() on the returned rate.Reservation is zero. I also chose to only expose a limited subset of the rate.Reservation struct (to use CancelAt), following from how the existing code does not expose the x/time/rate package.

Unit tests added to rate_limiter_test.go and distributor_test.go to check the cancel behaviour.

Which issue(s) this PR fixes:
Fixes #3804

Checklist

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

@stevesg stevesg force-pushed the distributor-rate branch 2 times, most recently from 79ec0c6 to d38b122 Compare February 15, 2021 13:23
@stevesg
Copy link
Contributor Author

stevesg commented Feb 15, 2021

Fixed a couple of typos in comments, and added issue number to changelog.

@stevesg stevesg force-pushed the distributor-rate branch 2 times, most recently from 35f5a4f to 76570af Compare February 15, 2021 13:43
@stevesg
Copy link
Contributor Author

stevesg commented Feb 15, 2021

Rebase, change issue number to PR number.

Change the handling of the rate limiting in the distributor such that when the ingestion fails, the reservation in the rate limiter is canceled, returning the tokens for future use in the proceeding requests.

Signed-off-by: Steve Simpson <[email protected]>
@stevesg
Copy link
Contributor Author

stevesg commented Feb 15, 2021

Fix lint

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Good job! I left a comment, but overall LGTM!

Signed-off-by: Steve Simpson <[email protected]>
Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

Good job, thanks! LGTM (modulo a couple of nits)

@pracucci pracucci requested a review from pstibrany February 15, 2021 19:08
Signed-off-by: Steve Simpson <[email protected]>
Copy link
Contributor

@pstibrany pstibrany left a comment

Choose a reason for hiding this comment

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

Thanks!

@pracucci pracucci merged commit 9ba848b into cortexproject:master Feb 17, 2021
@bboreham
Copy link
Contributor

bboreham commented Mar 1, 2021

What happens in the case that some samples succeed and some fail?
Looks like distributor acts as if they all failed.

pracucci added a commit to pracucci/cortex that referenced this pull request Mar 12, 2021
pracucci added a commit that referenced this pull request Mar 12, 2021
…ributor. (#3825)" (#3948)

This reverts commit 9ba848b.

Signed-off-by: Marco Pracucci <[email protected]>
pstibrany pushed a commit to pstibrany/cortex that referenced this pull request Mar 15, 2021
…ributor. (cortexproject#3825)" (cortexproject#3948)

This reverts commit 9ba848b.

Signed-off-by: Marco Pracucci <[email protected]>
(cherry picked from commit 6aa2a69)
pstibrany added a commit that referenced this pull request Mar 15, 2021
* Revert "Prevent failed ingestion from affecting rate limiting in distributor. (#3825)" (#3948)

This reverts commit 9ba848b.

Signed-off-by: Marco Pracucci <[email protected]>
(cherry picked from commit 6aa2a69)

* Update VERSION

Signed-off-by: Peter Štibraný <[email protected]>

Co-authored-by: Marco Pracucci <[email protected]>
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.

Distributor ingestion rate limit increased for retries due to ingestion failure
4 participants