fix: 增强 SQLite 数据库恢复与异常提示

This commit is contained in:
meijiali
2026-07-03 15:26:32 +08:00
parent 89c93b5051
commit 11f129c4aa
3 changed files with 119 additions and 1 deletions
+22
View File
@@ -532,6 +532,28 @@ fix: 完善失败重试与跳过边界
fix: 增强 SQLite 数据库恢复与异常提示
```
完成记录:
```text
完成日期:2026-07-03
相关 commitfix: 增强 SQLite 数据库恢复与异常提示
验证命令:
- .venv/bin/python -m pytest tests/unit/test_db_stability.py tests/integration/test_task_recovery.py -q
- docker compose up -d --build
- curl -f http://localhost:8000/health
- docker compose exec -T app python 检查 PRAGMA integrity_check 与 wal_checkpoint(TRUNCATE)
- .venv/bin/python -m pytest tests/unit tests/integration -q
- .venv/bin/python -m pytest tests/unit tests/integration --cov=app --cov-branch --cov-report=term-missing
验收结论:
- 启动时执行 PRAGMA integrity_check,异常时抛出明确 RuntimeError,不新增配置开关。
- 启动建表后执行 PRAGMA wal_checkpoint(TRUNCATE),将 WAL 写入主库并截断 WAL 文件。
- Docker 重建后,独立脚本可读到 WO-04 默认规模任务 4bdf36df-8ae4-4059-af98-602f4872dbaa 与 378b173a-a70f-4da1-b235-03e7632e614a。
- Uvicorn 进程不再持有 deleted app.db-wal/app.db-shm 文件句柄。
- Docker 重启后 running 任务恢复逻辑仍通过测试。
遗留问题:
- 数据库损坏备份策略和本地重置说明需要在 WO-09 用户操作文档中补充。
```
### WO-07 导出链路验收与文件质量优化
优先级:P1