fix(review): 代码审查 6 项修复(M2/M3/m1/m2/m3/m5)

集中修复 T8/T9/T11/T15 已实现代码的审查问题:
- M2 令牌桶 Lua 改用 Redis TIME(消除多节点时钟偏斜)
- M3 after 跨租户标记复查授权 + 无授权告警兜底
- m1 before 审计 MsgSeq/MsgRandom null 防御
- m2 HealthService 加 forceDown 开关,实测 DOWN 真返 503
- m3 countByStatus 排除 done(WHERE status IN (0,1,3))
- m5 配额查询异常不缓存(下次重试)
- 附带 app.yml console charset GBK→UTF-8
M1 限流审计/事务收窄暂缓。

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
yixiong
2026-07-09 09:52:13 +08:00
co-authored by Claude
parent 8e2c66b363
commit b4c6652f66
6 changed files with 45 additions and 16 deletions
@@ -37,12 +37,27 @@ public class HealthService {
@Inject
private JedisPool jedisPool;
/** 运维测试用:强制返回 DOWN,验证 LB/k8s 探针摘流(默认关) */
@Inject("${imutil.health.forceDown:false}")
private boolean forceDown;
/**
* 采集健康指标
*
* @return 含 status / pg / redis / distQueue / timestamp
*/
public Map<String, Object> health() {
// 运维测试开关:强制 DOWN,验证探针据 503 摘流
if (forceDown) {
Map<String, Object> r = new LinkedHashMap<>();
r.put("status", "DOWN");
r.put("pg", "DOWN");
r.put("redis", "UP");
r.put("distQueue", new LinkedHashMap<>());
r.put("forced", true);
r.put("timestamp", OffsetDateTime.now().toString());
return r;
}
Map<String, Object> distQueue = new LinkedHashMap<>();
boolean pgUp;
try {
@@ -58,8 +73,8 @@ public class HealthService {
}
distQueue.put("pending", cnt[0]);
distQueue.put("processing", cnt[1]);
distQueue.put("done", cnt[2]);
distQueue.put("dead", cnt[3]);
// done(status=2) 不统计:无索引且无限增长,健康检查只关心堆积/死信
pgUp = true;
} catch (Exception e) {
log.warn("健康检查 PG 查询失败 : {}", e.getMessage());