fix: 拒绝环形 DAG 并避免无效工作流堵塞任务队列
This commit is contained in:
@@ -150,9 +150,24 @@ class WorkflowScheduler:
|
||||
return
|
||||
|
||||
# 解析并校验 DAG,随后计算拓扑执行顺序。
|
||||
definition = WorkflowDefinition.from_dict(version["definition"])
|
||||
definition.validate()
|
||||
ordered = topological_sort(definition)
|
||||
#
|
||||
# 任何预检异常(缺字段/边引用不存在/环形依赖)都必须在这里把任务标
|
||||
# FAILED:修复前这段在 try 之外,异常直接冒到 _loop 被吞掉,任务停在
|
||||
# QUEUED,next_queued_run 每轮拾起同一条队首记录,后续任务全部堵塞
|
||||
# (R04:环形 DAG 卡死队列)。历史无效版本无法删除,只能就地判失败。
|
||||
try:
|
||||
definition = WorkflowDefinition.from_dict(version["definition"])
|
||||
definition.validate()
|
||||
ordered = topological_sort(definition)
|
||||
except Exception as exc: # noqa: BLE001
|
||||
logger.exception("任务 %s 工作流定义无效,标记失败: %s", run_id, exc)
|
||||
self.db.update_run(
|
||||
run_id,
|
||||
status="FAILED",
|
||||
error=str(exc),
|
||||
updated_at=_now_iso(),
|
||||
)
|
||||
return
|
||||
# 从已登记产物重建已完成节点的输出,支持暂停后断点续跑。
|
||||
outputs_by_node = self.db.restore_run_outputs(run_id)
|
||||
run_started = time.monotonic()
|
||||
|
||||
Reference in New Issue
Block a user