perf: 依赖数据库 CASCADE/SET NULL 替代手动清理关联表,缩短删除事务

- 批量删除移除 cleanup_key_references 手动清理,改为依赖 FK CASCADE/SET NULL
- video_tasks.key_id FK 增加 ondelete="SET NULL",附带幂等迁移脚本
- _sync_delete 增加 statement_timeout 和任务级超时保护
- 批量导入在每次 await 前释放闲置 DB 连接,按批次提交写入避免长事务
- 前端轮询改为先查后等,首次查询不再多等一个间隔
This commit is contained in:
fawney19
2026-03-09 03:48:20 +08:00
parent 654ce89541
commit fa69287449
8 changed files with 468 additions and 18 deletions

View File

@@ -585,7 +585,6 @@ async function pollDeleteTask(
const deadline = Date.now() + DELETE_POLL_MAX_MS
let consecutiveFailures = 0
while (Date.now() < deadline) {
await new Promise((r) => setTimeout(r, DELETE_POLL_INTERVAL_MS))
try {
const task = await getPoolBatchDeleteTask(providerId, taskId)
consecutiveFailures = 0
@@ -599,6 +598,7 @@ async function pollDeleteTask(
return { status: 'failed', deleted: 0 }
}
}
await new Promise((r) => setTimeout(r, DELETE_POLL_INTERVAL_MS))
}
return { status: 'failed', deleted: 0 }
}