Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[RateLimiter] Fix sliding_window misbehaving with stale records#40141

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:5.2fromxesxen:no-negative-hitcount
Feb 11, 2021

Conversation

@xesxen
Copy link
Contributor

@xesxenxesxen commentedFeb 9, 2021
edited
Loading

QA
Branch?5.2
Bug fix?yes
New feature?no
Deprecations?no
Tickets-
LicenseMIT
Doc PR-

Currently the SlidingWindow RateLimiter returns a negative value for getHitCount if the previous SlidingWindow was too long ago. This results in a really high value fromSlidingWindowLimiter::getAvailableTokens() which is higher than the configured limit.

This limits the value of percentOfCurrentTimeframe inSlidingWindow::getHitCount() to 1 so it can't result in a negative hitcount.

The 2nd fix fixes the SlidingWindow instance (essentially) not storing hits if the previous instance is way in the past, as the next instance will still be "in the past". This causes RateLimit to behave as if it were disabled until it has caught up again, which could take a long time when it is configured with a small window size.

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 5.x branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@xesxenxesxenforce-pushed theno-negative-hitcount branch 2 times, most recently from1073a52 to16a3f0cCompareFebruary 10, 2021 00:30
@xesxenxesxen changed the title[RateLimiter] Fix remaining tokens for sliding_window overflowing the configured limit[RateLimiter] Fix sliding_window misbehaving with stale recordsFeb 10, 2021
@xesxen
Copy link
ContributorAuthor

Essentially only the last 2 commits are needed to fix the issue, but getHitCount() returning <0 even when it is invalid is still a bug worth fixing imho (the 1st commit).

If wanted, I can remove the 1st commit from this PR.

@fabpot
Copy link
Member

Thank you@xesxen.

@fabpotfabpot merged commitb636e66 intosymfony:5.2Feb 11, 2021
@fabpotfabpot mentioned this pull requestMar 4, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@jderussejderussejderusse approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

5.2

Development

Successfully merging this pull request may close these issues.

4 participants

@xesxen@carsonbot@fabpot@jderusse

[8]ページ先頭

©2009-2025 Movatter.jp