[BUG] Sliding-window rate limiter ignores requestCount and over-reports remaining requests
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 83/100
Research direction
Read RedisRateLimiter.java and sliding_window_request_rate_limiter.lua, then compare how the token bucket and leaky bucket scripts use ARGV[4]. Update the sliding window behavior to account for requestCount when checking capacity, recording usage, and reporting remaining requests. Done when the behavior matches the expected results in the issue; add or run the relevant rate limiter tests.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
RedisRateLimiter passes requestCount as the fourth script argument for every algorithm:
request_rate_limiter.lua (token bucket) and request_leaky_rate_limiter.lua read it as local requested = tonumber(ARGV[4]). sliding_window_request_rate_limiter.lua never reads ARGV[4]:
local remain_request = capacity - last_requested
local allowed_num = 0
if (last_requested < capacity) then
allowed_num = 1
redis.call('zadd', tokens_key, now, timestamp_key)
end
...
return { allowed_num, remain_request }
- A rule with
algorithmName=slidingWindowandrequestCount=Nconsumes 1 unit per request instead of N, so it admits N times more requests than the same handle undertokenBucketorleakyBucket. remain_requestis computed before the current request is added, so the reported remaining count is one higher than the real value after an allowed request.
Expected Behavior
The sliding window admits a request only if last_requested + requestCount <= capacity, records requestCount units, and returns capacity - last_requested - requestCount as the remaining count, consistent with the other algorithms.
Steps To Reproduce
- Enable the rateLimiter plugin with Redis.
- Create a rule with
algorithmName=slidingWindow,replenishRate=10,burstCapacity=10,requestCount=5. - Send 10 requests within one second. All 10 are allowed, while
tokenBucketwith the same handle allows 2.
Environment
ShenYu version(s): master @ 9dd9a12fb
Debug logs
No response
Anything else?
Found by static code review; I have not yet run the reproduction against Redis.
- Dominant language
- Java
- Stars
- 8.9k
- Forks
- 3.1k
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 362
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/shenyu
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
[BUG] Boolean tars parameter parsed via Byte.valueOf → NumberFormatExceptionPossibly taken @yangjj-iso claimed this 26 days ago. Openplugin: tars priority: medium type: bug
Difficulty 1/5 Under an hour Newbie friendliness 82/100
apache/shenyu#6736 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG] ShenyuMcpResponseDecorator reads buffer before super.writeWith, corrupting forwarded bodyMay be free again A pull request for this issue was closed without being merged. Openfeature: plugin priority: high type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/shenyu#6641 · 1 comment ·
Maintainers usually reply within 1 day
-
admin: permission priority: medium type: bug
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
apache/shenyu#6549 · 1 comment ·
Maintainers usually reply within 1 day
-
[BUG] Node sync auth and metadata deletes unsubscribe the wrong cache keyPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
apache/shenyu#6478 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
hiero-ledger/hiero-mirror-node#14665 ·
Maintainers usually reply within 1 day
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
cadence-workflow/cadence#8745 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
oracle/graalvm-reachability-metadata#12168 ·
Maintainers usually reply within 1 day
-
area/frontend area/test kind/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
camunda/camunda#69073 · 1 comment ·
Maintainers usually reply within 1 day
-
Patient profile returns a server error for a person with observation periods but no clinical recordsPossibly taken @DG47 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day