[BUG] Upgrade from 2.x: EWMA rate limiter hits WRONGTYPE on sliding-window keys left in Redis
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 活躍
- 技術堆疊
- redis, typescript
研究方向
Start by tracing the EWMA rate limiter’s Lua script and the code that builds its Redis keys; the issue names the colliding connection and message key patterns. Check how the existing sliding-window strategy stores those keys and inspect the upgrade notes. Done means upgrading with legacy sorted-set keys no longer causes WRONGTYPE errors, with the behavior covered for both connection and message limits.
由索引模型根據 Issue 內容生成。
描述
Describe the bug
After upgrading from 2.x with the existing cache volume, client workers log on every new connection/message:
uncaught error: [ErrorReply: WRONGTYPE Operation against a key holding the wrong kind of value script: <sha>, on @user_script:6.]
2.x used the sliding-window limiter, which stores ${remoteAddress}:connection:${period} and ${client}:message:${period} as sorted sets. Since #476 the default limits.rateLimiter.strategy is ewma, whose Lua script does HGET/HSET on the same key names. The old zset keys stay in Redis until their TTL expires (up to the longest configured period), and until then those clients hit the error path.
To Reproduce
- Run 2.x for a while (rate-limit keys accumulate in the
cachevolume). - Upgrade to 3.x keeping the volume, start the relay.
docker logs nostreamshows the WRONGTYPE errors above;redis-cli type <ip>:connection:<period>→zset.
Expected behavior
Upgrading does not require manual Redis cleanup.
System
- Version: 2.1.0 → 3.4.1, default
rateLimiter.strategy: ewma,redis:7.0.5-alpine3.16
Workaround we used
Delete only the conflicting legacy keys (7 058 in our case), after which the errors stopped:
for p in '*:connection:*' '*:message:*'; do
redis-cli -a "$REDIS_PASSWORD" --scan --pattern "$p" | while read k; do
[ "$(redis-cli -a "$REDIS_PASSWORD" type "$k")" = zset ] && redis-cli -a "$REDIS_PASSWORD" del "$k"
done
done
Suggestion
Either namespace the EWMA keys (e.g. ewma: prefix) so they cannot collide with sliding-window keys — this also helps when an operator switches strategy back and forth — or make the EWMA script self-healing:
if redis.call('TYPE', key).ok ~= 'hash' then redis.call('DEL', key) end
plus a line in the upgrade notes.
- 主要語言
- TypeScript
- 星號
- 829
- 分支
- 234
- 平均合併
- 16 小時 13 分鐘
- 30 天內合併 PR
- 74
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
cameri/nostream 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
Website
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 55/100
維護者通常 1 天內回覆
-
[BUG] LNbits >= 1.0: ISO 8601 time/expiry parsed as unix seconds, paid admissions never confirmed未關閉
難度 2/5 1-3 小時 新手友好度 25/100
維護者通常 1 天內回覆
-
feat(payments): let clients see their subscription tier可能已有人在做 @Priyanshubhartistm 於 1 天前認領。 未關閉enhancement
cameri/nostream#925 · 已指派 1 人 ·
維護者通常 1 天內回覆
相似的 Issue
-
area:agent-view area:tui bug platform:macos
難度 2/5 1-3 小時 新手友好度 70/100
anthropics/claude-code#104558 ·
維護者通常 1 天內回覆
-
updater
難度 2/5 1-3 小時 新手友好度 68/100
UniversityOfHelsinkiCS/oodikone#5141 ·
-
maintanance
難度 2/5 1-3 小時 新手友好度 74/100
inmanta/web-console#7606 ·
維護者通常 1 天內回覆
-
bug skills
難度 2/5 1-3 小時 新手友好度 77/100
equinor/fusion-framework#5846 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 74/100