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

fix(quotas): Make redis rate limiter work with quantity 0 [INGEST-1656] #1519

Merged
merged 4 commits into from
Oct 7, 2022

Conversation

jjbayer
Copy link
Member

@jjbayer jjbayer commented Oct 6, 2022

For #1515, it is required to check for a required quota of another data category without incrementing it. This PR updates the Redis LUA script to support a rate limiting quantity of 0, which checks for existing rate limits without incrementing internal counters.

The rate limiter gains a new explicit branch to check whether the quantity is 0. We could have indirectly achieved the same effect with max(quantity, 1).

@jan-auer jan-auer marked this pull request as ready for review October 7, 2022 10:03
@jan-auer jan-auer requested a review from a team October 7, 2022 10:03
@@ -57,8 +63,10 @@ if not failed then
local k = i * 2 + 1
local v = i * 3 + 1

redis.call('INCRBY', KEYS[k], ARGV[v + 2])
redis.call('EXPIREAT', KEYS[k], ARGV[v + 1])
if tonumber(ARGV[v + 2]) > 0 then
Copy link
Member

Choose a reason for hiding this comment

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

Consider this an optimization. I'm assuming that the check is quite a bit faster than executing the two commands below.

@flub flub assigned jan-auer and unassigned flub Oct 7, 2022
* master:
  ref: Remove unused rate_limits from ProcessEnvelopeState (#1516)
@jan-auer jan-auer enabled auto-merge (squash) October 7, 2022 10:47
@jan-auer jan-auer merged commit 926827a into master Oct 7, 2022
@jan-auer jan-auer deleted the feat/quota-quantity-0 branch October 7, 2022 11:05
jan-auer added a commit that referenced this pull request Oct 7, 2022
* master:
  fix(quotas): Make redis rate limiter work with quantity 0 (#1519)
  ref: Remove unused rate_limits from ProcessEnvelopeState (#1516)
  fix(quotas): Use correct string spelling for TransactionProcessed (#1514)
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