fix: 4 个安全/正确性问题

1. (High) 定时任务 FOR UPDATE 无事务保护
   → BEGIN/COMMIT 事务包裹 fetch + update
2. (Medium) 审批 DB 状态未更新
   → handle_reply 更新 status/consumed_at
3. (Medium) 过期审批未清理
   → 每 30s tokio::spawn 调用 clean_expired
4. (Low) 非零退出丢弃 stdout
   → 退时 stderr 空则用 stdout 作为错误信息
This commit is contained in:
2026-06-02 14:32:18 +08:00
parent 3f447668b8
commit a32593bc25
4 changed files with 95 additions and 44 deletions
+8
View File
@@ -438,6 +438,14 @@ async fn cmd_listen(
.await;
});
info!("定时任务调度器已启动");
// 审批定期清理
let approval_clean = approval_manager.clone();
tokio::spawn(async move {
loop {
tokio::time::sleep(std::time::Duration::from_secs(30)).await;
approval_clean.clean_expired().await;
}
});
}
info!("开始监听消息 (llm={}, echo={})...", enable_llm, echo);