# Fix logic errors in \`RateLimiter\` \(\#12421\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/4acfab689ed3e76b540f1ef6fda4c4958cda7ff7)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 4acfab689ed3e76b540f1ef6fda4c4958cda7ff7

Requested commit: 4acfab689ed3e76b540f1ef6fda4c4958cda7ff7

Commit: 4acfab689ed3e76b540f1ef6fda4c4958cda7ff7

Tree: b5b5d5cdf35d197606693837ea399395aaf71a87

Author: Antonio Scandurra

Committer: GitHub

## Message

```
Fix logic errors in `RateLimiter` (#12421)

This pull request fixes two issues in `RateLimiter` that caused
excessive rate-limiting to take place:

- c19083a35c89a22395595f8934c117a14943ed24 fixes a mistake that caused
us to load buckets from the database incorrectly and set the
`refill_time_per_token` to equal the `refill_duration`. This was the
primary reason why rate limiting was acting oddly.
- 34b88d14f6d9fde4d967554fc2e81498c1be3e26 fixes another slight logic
error that caused tokens to be underprovisioned. This was minor compared
to the bug above.

Release Notes:

- N/A
```

## Parents

- [3c6c85039028516799e285b9c3f27c3f5bddee1b](https://git.cafe/gitcafe/zed/commit/3c6c85039028516799e285b9c3f27c3f5bddee1b?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/4acfab689ed3e76b540f1ef6fda4c4958cda7ff7?format=markdown)
