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] bug #42194 fix: sliding window policy to use microtime#43677

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.4fromjlekowski:sliding-policy-microtime
Oct 24, 2021
Merged

[RateLimiter] bug #42194 fix: sliding window policy to use microtime#43677

fabpot merged 1 commit intosymfony:5.4fromjlekowski:sliding-policy-microtime
Oct 24, 2021

Conversation

@jlekowski
Copy link
Contributor

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#42194
LicenseMIT
Doc PRsymfony/symfony-docs

Other parts ofRateLimiter usemicrotime(), while sliding window policy usestime() instead. That means the window may expire only up to 0.(9) seconds after the interval. Below an example that fails (window not expired) majority of the times (window is expired only if it starts e.g. at 1634992063.4999 and is checked at 1634992065.5000 - withtime() rounding it would be 3 seconds).

<?phpuseSymfony\Component\RateLimiter\Policy\SlidingWindow;require_once'./vendor/autoload.php';$window =newSlidingWindow('some_id',2);sleep(2);// mimic $limit->wait();var_dump($window->isExpired());// false - same second

@carsonbotcarsonbot added this to the5.3 milestoneOct 23, 2021
@carsonbotcarsonbot changed the titlebug #42194 [RateLimiter] fix: sliding window policy to use microtime[RateLimiter] bug #42194 fix: sliding window policy to use microtimeOct 23, 2021
$this->assertFalse($new->isExpired());
}

publicfunctiontestCreateFromPreviousWindowUsesMicrotime()
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

These tests consistently pass after the changes. The old code would inconsistently fail, though (depend on themicrotome(true) result at the moment of running the test.

@jlekowski
Copy link
ContributorAuthor

@Nyholm,@wouterj - please have a look at this PR.

Copy link
Member

@NyholmNyholm left a comment

Choose a reason for hiding this comment

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

Thank you

@fabpotfabpot modified the milestones:5.3,5.4Oct 24, 2021
@fabpot
Copy link
Member

Thank you@jlekowski.

@fabpotfabpot merged commit85bf403 intosymfony:5.4Oct 24, 2021
@chalasr
Copy link
Member

This PR introduced a randomly failing testhttps://github.com/symfony/symfony/runs/3990643552?check_suite_focus=true#step:8:987.@jlekowski could you please have a look?

@jlekowski
Copy link
ContributorAuthor

@chalasr, I'll have a look at it. Thanks for letting me know.

chalasr added a commit that referenced this pull requestOct 26, 2021
…se microtime - fix test (jlekowski)This PR was merged into the 5.4 branch.Discussion----------[RateLimiter] bug#42194 fix: sliding window policy to use microtime - fix test| Q             | A| ------------- | ---| Branch?       | 5.4| Bug fix?      | yes| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       |Fix#42194 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License       | MIT| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->As pointed out in the comment#43677 (comment), `RateLimitTest::testWaitUsesMicrotime()` fails intermittently.I have looked at all `PHPUnit` actions since the test was introduced and interestingly, the fails only occurred during `7.2` test, and the time difference was always ~1.3s.Commits-------e616963 bug#42194 [RateLimiter] fix: sliding window policy to use microtime - fix test
This was referencedNov 5, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@NyholmNyholmNyholm approved these changes

@chalasrchalasrAwaiting requested review from chalasr

@wouterjwouterjAwaiting requested review from wouterj

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

[RateLimiter] SlidingWindow to use microtime() instead of time()

5 participants

@jlekowski@fabpot@chalasr@Nyholm@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp