Skip to content

PublishNew was allowing 1 new crate an hour rather than every 10 minutes #6961

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

Merged
merged 2 commits into from
Aug 11, 2023

Conversation

carols10cents
Copy link
Member

@carols10cents carols10cents commented Aug 11, 2023

In #6875, @pietroalbini said:

With this PR, the rate limits are:

Action Burst amount Refill time
Publish new crates 5 1 every 10 minutes
Publish updates to existing crates 30 1 every minute
Yanking or unyanking 100 1 every minute

but the code didn't match that intention, which explains why we were getting so many emails asking for rate limit increases since that PR went out.

The problem was that the default_rate_seconds for PublishNew was set to 60 * 60, aka 1 hour, when the intention was that it would be set to 10 * 60, or 10 minutes.

I added a new test, and for PublishNew it fails with:

---- rate_limiter::tests::default_rate_limits stdout ----
thread 'rate_limiter::tests::default_rate_limits' panicked at 'assertion failed: `(left == right)`
  left: `[2023-08-11T19:15:38, 2023-08-11T19:25:38, 2023-08-11T19:35:38, 2023-08-11T19:45:38, 2023-08-11T19:55:38, 2023-08-11T20:05:38, 2023-08-11T20:15:38, 2023-08-11T20:25:38, 2023-08-11T20:35:38, 2023-08-11T20:45:38]`,
 right: `[2023-08-11T19:05:38, 2023-08-11T19:05:38, 2023-08-11T19:05:38, 2023-08-11T19:05:38, 2023-08-11T19:05:38, 2023-08-11T20:05:38, 2023-08-11T20:05:38, 2023-08-11T20:05:38, 2023-08-11T20:05:38, 2023-08-11T20:05:38]`', src/rate_limiter.rs:212:9

because the last_refill times get set to the time at which you're publishing if you're not rate limited.

The CI run for the first commit shows the failure, then the second commit shows the test passing (modulo the flaky test).

@carols10cents carols10cents changed the title Failing test for incorrect default refill rate PublishNew was allowing 1 new crate an hour rather than every 10 minutes Aug 11, 2023
Copy link
Member

@pietroalbini pietroalbini left a comment

Choose a reason for hiding this comment

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

Whelp, good catch!

Copy link
Contributor

@LawnGnome LawnGnome left a comment

Choose a reason for hiding this comment

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

Thanks!

@carols10cents carols10cents merged commit 86531b3 into main Aug 11, 2023
@carols10cents carols10cents deleted the refill-rate-fix branch August 11, 2023 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants