fix: restart wipes stats history — LoadAudit replayed only the last 3000 lines (92% of which are 3s access events) and fed access rows into aggregates; now replays every real request into totals/quota windows, skips event rows, tolerates >64KB lines; +TestLoadAuditFullReplay

This commit is contained in:
JianFeeeee
2026-08-11 08:42:13 +08:00
parent 6221502adc
commit e8ef73321c
3 changed files with 82 additions and 20 deletions

View File

@ -224,5 +224,6 @@ p==nil → 400/404!TryAcquire → 429 busy快速失败
- [x] **P3-32026-08-10审计分类与 jsonl 轮转**`Stats.byStatus map[int]*Stat`402 欠费/400 schema 等按状态码独立计数不触发 provider 退避`Snapshot.by_status` 有序输出audit 文件超 `auditRotateBytes`(64MB, var 可测) 轮转 `rename <path>.<unix>.old` 并保留最新 `auditKeepOld`(10) ——`rotateAuditLocked` mu `Record`/`AppendAudit` 内触发
- [x] **P3-42026-08-10运维项代码部分**`main.go` 启动告警——gateway_keys 为空 / 命中种子 keysk-gw-local-0001 提示轮换listen 绑定 0.0.0.0/:: 提示收敛内网生产实践 admin key内网绑定随本次上线执行
- [x] **P3-52026-08-10测试**新增 `stats_test.go`by_status 断言轮转保留上限Record 路径轮转gateway 新增 `TestAutoStatesReportChainHealth`states 契约失败后 fail_count>0+coolingPUT 复位归零);`go vet ./...` + `go test ./...` 全绿。
- [x] **P3-62026-08-10WebUI 右键菜单无法关闭(用户实测)**:根因——关闭依赖 `document` 冒泡阶段 once-click 监听,而优先级页块/密钥砖自己的 click 处理 `stopPropagation()` 阻断冒泡 → 菜单永不关闭;修复:改为 **document 捕获阶段**全局 `click`+`mousedown` 关闭捕获先于一切目标处理器stopPropagation 无法拦截),优先级页与密钥页共用 `showCtx` 一并修复。
- [ ] **P3-7**:推送 origin → 生产机 pull → `-tags luajit` 全量回归(含 P2-7→ 部署 `/usr/local/bin/llmsproxy` + 重启 service → 观察。
- [x] **P3-62026-08-10WebUI 右键菜单无法关闭(用户实测)**:根因——`showCtx` 创建菜单后从未赋值 `ctxEl``hideCtx()` 恒为空操作),任何路径(点菜单项/点外部/二次右键)都关不掉;补 `ctxEl = w`,优先级页与密钥页共用 `showCtx` 一并修复(这也是最初版本就存在的 bug
- [ ] **P3-7**:推送 origin → 生产机 pull → `-tags luajit` 全量回归(含 P2-7→ 部署 `/usr/local/bin/llmsproxy` + 重启 service → 观察。
- [x] **P3-82026-08-11审计回放修复用户实测**:重启后统计只剩最后 3000 行≈5.3M tokens历史 273M 消失、且记录里全是 access 脏行——根因 `LoadAudit`:① 只取文件尾 3000 行(而 92% 行是每 3s 的 access 事件);② access/事件行type 空)被当请求灌入聚合;③ Scanner 默认 64KB 截断风险。修复:回放**全部真实请求行**进聚合(恢复 totals/配额窗口),仅视图环形缓冲限 maxRecs跳过 type 空的行;`sc.Buffer` 抬到 16MB。新增 `TestLoadAuditFullReplay`access/坏 JSON/超大行混合回放断言)。