[稳定性] P2:公开投稿限流器清理过期记录,避免内存一直增长 #44

Closed
opened 2026-10-31 08:38:46 +08:00 by lixu · 1 comment
Owner

现状

adminhandler/ratelimit.go 按 IP 记录投稿时间,过期的 IP 不会从 map 中删除,来过的 IP 越多内存越大。

要求

  • 定期(距上次清理超过一个窗口时,在 allow 中顺带执行)删除所有记录都已过期的 key。
  • 保持现有限流行为不变。

验收

  • 测试:过期 key 被清理;未过期 key 和限流结果不受影响。

来源:只读审查 main@36f9c95(2026-10-23)。

## 现状 `adminhandler/ratelimit.go` 按 IP 记录投稿时间,过期的 IP 不会从 map 中删除,来过的 IP 越多内存越大。 ## 要求 - [ ] 定期(距上次清理超过一个窗口时,在 allow 中顺带执行)删除所有记录都已过期的 key。 - [ ] 保持现有限流行为不变。 ## 验收 - 测试:过期 key 被清理;未过期 key 和限流结果不受影响。 来源:只读审查 main@36f9c95(2026-10-23)。
lixu closed this issue 2026-10-31 09:45:29 +08:00
Author
Owner

已由 #54 合并(main c163f2b7)。合并前已把最新 main 合入分支,并在本地按 .github/workflows/ci.yml 跑通:Go 1.27.3 的 gofmt/vet/build/test(PostgreSQL 16,后台 DB 测试 0 跳过)、Python ruff/pytest(52 通过)、迁移 up/down、两份 compose config;#46 另做了 SIGTERM 优雅退出验证(退出码 0)。生产尚未部署。

Written by Devin

已由 #54 合并(main c163f2b7)。合并前已把最新 main 合入分支,并在本地按 .github/workflows/ci.yml 跑通:Go 1.27.3 的 gofmt/vet/build/test(PostgreSQL 16,后台 DB 测试 0 跳过)、Python ruff/pytest(52 通过)、迁移 up/down、两份 compose config;#46 另做了 SIGTERM 优雅退出验证(退出码 0)。生产尚未部署。 [Written by Devin](https://app.devin.ai/sessions/e8ebad4bb5c74fe8bf8f4a2c8825de40)
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lixu/goods#44