fix: 心跳超时从 20 分钟回收重跑改为 10 分钟强制结束标注超时失败

running 任务 updated_at 超 10 分钟未更新(进程崩溃/协程挂起僵尸),原逻辑回收回
submitted 重跑,改为 state=failed + last_error=心跳超时。中文 last_error 让
_classify_failure 判 fault 不自动重跑,failed_poller 报故障通知用户。
This commit is contained in:
ymq 2026-08-18 10:53:13 +08:00
parent 7ed0ed9b80
commit feb88aca02

View File

@ -585,12 +585,13 @@ def load_pipeline_service():
while True:
try:
async with poll_db.sqlorContext("pipeline") as sor:
# 回收僵尸 running 任务:进程崩溃/协程挂起遗留(心跳超时未更新)。
# 阈值 20 分钟 > LLM 单轮最坏时长3 次 × 300s 重试 ≈ 15 分钟),避免误杀慢任务。
# 心跳超时处理running 任务 updated_at 超 10 分钟未更新 = 进程崩溃/协程挂起(僵尸),
# 强制结束并标注超时失败不回收重跑。last_error 用中文「心跳超时」,
# 让 _classify_failure 判 fault不自动重跑failed_poller 报故障通知用户。
await sor.sqlExe(
"UPDATE pipeline_tasks SET state='submitted', claimed_by=NULL, updated_at=NOW() "
"UPDATE pipeline_tasks SET state='failed', claimed_by=NULL, last_error='心跳超时(10分钟未更新),已强制结束', updated_at=NOW() "
"WHERE state='running' AND pipeline_id='role_task' "
"AND updated_at < (NOW() - INTERVAL 20 MINUTE)", {})
"AND updated_at < (NOW() - INTERVAL 10 MINUTE)", {})
# 全局并发 agent 数限制max_concurrent_agentsappbase params 表,默认 3
# 以 DB state='running' 计数为准(权威),超出上限时本轮回合不再派发。