[BUG] Upgrade from 2.x: EWMA rate limiter hits WRONGTYPE on sliding-window keys left in Redis
维护者通常 1 天内回复
评估
- 难度
- 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
- 平均合并
- 17 小时 6 分钟
- 30 天内合并 PR
- 92
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
cameri/nostream 的其他 Issue
-
factory rewrite rust
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
factory rewrite rust
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
test: user-subscription specs fail outside UTC, so the pre-commit hook cannot pass可能已有人在做 @tejasvasingh2004 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug factory rewrite rust
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug factory rewrite rust
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
相似的 Issue
-
Plugin: sheet music can't be scrolled by hand before playback可能已有人在做 @snakajima 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
receptron/jinglescript#51 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 9 天内回复
-
clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster P3
难度 2/5 1-3 小时 新手友好度 78/100
openclaw/openclaw#186424 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
chore(worker): five module header comments describe the code from before later issues changed it未关闭area:dev U2-later
难度 2/5 1-3 小时 新手友好度 78/100
bentleypark/aiwatch#1824 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
Pal-AI-Lab/Coopanion#469 ·
维护者通常 1 天内回复