apache / apache/shenyu

[BUG] Concurrent rate-limiter zset has no TTL; leaked entries permanently block the key

Open
#6,646 1 comment 0 reactions 0 assignees View on GitHub
plugin: ratelimiter priority: high type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: High
- files: `shenyu-plugin/shenyu-plugin-fault-tolerance/shenyu-plugin-ratelimiter/src/main/resources/META-INF/scripts/concurrent_request_rate_limiter.lua:18-33`; callback at `.../algorithm/ConcurrentRateLimiterAlgorithm.java:59`
- description: The concurrent lua does `zadd` but the only `setex` line is commented out (`-- redis.call("setex", key, timestamp)` at line 32). Every other algorithm sets an explicit TTL. The concurrent limiter relies solely on the `doFinally` callback (`opsForZSet().remove(...).subscribe()`) to remove entries, and that call is fire-and-forget with no error handling. If the gateway crashes, the request errors before `doFinally`, or the Redis `remove` fails, the member stays in the zset forever.
- impact: A few lost cleanup callbacks permanently disable concurrency limiting for the affected key; no self-healing.
- suggested_fix: Add `redis.call("expire", key, )` in the lua; guard the callback `subscribe` with error logging.
- confidence: High
- related_existing: none

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/00-consolidated-critical-high.md`](docs/scan2-2026-08-02/00-consolidated-critical-high.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the concurrent_request_rate_limiter.lua lines 18-33 and the callback in ConcurrentRateLimiterAlgorithm.java:59; compare TTL handling in the other rate-limiter algorithms. Done means leaked sorted-set members expire after a bounded interval and cleanup failures are logged rather than silently discarded.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, lua, redis
Domain
api, backend, distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.