Skip to content

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

Merged
jan-auer merged 4 commits into
masterfrom
feat/quota-quantity-0
Oct 7, 2022
Merged

jan-auer merged 4 commits into
masterfrom
feat/quota-quantity-0

Conversation

@jjbayer

@jjbayer jjbayer commented Oct 6, 2022 •

Copy link
Copy Markdown
Member

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

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
Copy Markdown
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