Files
Nexus/docs/changelog/2026-06-08-sync-log-purge.md
T
Nexus Agent 69068e2e39 feat(ops): server_batch 回收、sync_logs 清理与 Agent 安装跳过
部署对齐三项后端能力:启动/周期收尾僵尸批量任务、30 天推送日志 purge、已安装且版本不低于主站时跳过批量安装 Agent。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 15:23:03 +08:00

38 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-06-08 — sync_logs 30 天自动清理
## 摘要
primary worker 每日删除 `started_at` 超过 30 天的 `sync_logs` 记录(启动后立即执行首轮),对齐 `design-standards.md` 保留策略。
## 动机
推送历史仅存 MySQL、无 TTL,长期运行后表体积持续增长,影响列表查询与备份。
## 涉及文件
- `server/infrastructure/database/sync_log_repo.py``purge_older_than`、常量 `SYNC_LOG_RETENTION_DAYS=30`
- `server/background/sync_log_purge.py` — 24h 周期循环
- `server/main.py` — primary worker 注册后台任务
- `tests/test_sync_log_purge.py`
## 迁移 / 重启
- 无 schema 变更
- **需重启 API**
## 行为
| 项 | 值 |
|----|-----|
| 保留窗口 | 30 天(`started_at` |
| 执行频率 | 启动后首轮 + 每 24h |
| 删除方式 | 每批最多 1000 行,循环至无匹配 |
## 验证
```bash
pytest tests/test_sync_log_purge.py -q
bash scripts/local_verify.sh
# 可选:INSERT 一条 started_at=31天前 的 sync_log,重启 API 后确认已删除
```