[Bug] 大产物写入 run_artifacts 失败后,节点成功状态未落库,Run 永久停留在 running
Component / host
Platform — runner / sandbox
Edition
Platform
LoopForge version
loopforge-platform:qianfan-0.4.0
What happened?
当某个 Agent/script 节点产出超过 65,535 字节 的必需产物时,PutRun 在写 run_artifacts 时会因为 MySQL TEXT 列上限而失败: Error 1406 (22001): Data too long for column 'content' at row 1 但平台只记录了一条日志,没有把这次写入失败升级为节点失败;节点状态仍显示 running,产物也没有入库,Run 因此永久卡在 running。本次真实运行中,节点实际已经完成、门禁也已经通过,却因为这次静默失败无法继续。
环境 LoopForge 镜像:loopforge-platform:qianfan-0.4.0 Go:1.26.11,Linux amd64 MySQL:8.4 存储驱动:mysql 执行模式:cloud
Reproduction
创建一个 SOP,节点产出一个必需 Markdown 产物,例如 artifacts/design-draft.md。
让产物大小超过 65,535 字节(本次为 98,645 字节)。
正常情况下节点完成、submit_gate_result pass、产物契约校验通过。
观察平台日志:
put run
实际行为 Agent 已经退出,process.finished 为 0 gate.submit.received 为 pass artifact.contract.validated 通过 artifact.published 也打出了日志 但数据库中没有该产物,节点状态也没有变成 succeeded Run 继续停留在 running,只能通过重启平台/恢复流程处理
期望行为 大产物(在 maxArtifactBytes 允许范围内)应能正常写入并推进 Run。 如果产物或状态写入数据库失败,节点应明确失败,并显示可操作错误,而不是留下 running。 不应出现“节点无进程、无日志、Run 仍 running”的僵尸状态。
Sanitized diagnostics
根因分析
1. 代码允许 1MB,但数据库列只有 64KB
internal/engine/artifacts.go:19:
const maxArtifactBytes = 1 << 20 // 1MB
internal/repo/models.go:435:
Content string `gorm:"column:content;type:text"`
MySQL TEXT 上限是 65,535 字节;本次 design-draft.md 是 98,645 字节,直接触发 Error 1406。
2. 产物写入失败后,节点状态没有单独落库
internal/repo/runs.go 的 PutRun 在同一个事务里同时写入:
run_nodes(节点状态)
run_artifacts(产物 content)
run_artifacts 写入失败会让整个事务失败,节点成功状态也一起丢失。
internal/engine/node_execute.go 中:
e.updateRun(runID, func(r *domain.Run) {
...
nr.Status = "succeeded"
})
for _, artifact := range artifacts {
e.observe(runID, node.ID, ... "artifact.published" ...)
}
updateRun 返回的 bool 被忽略;即使 PutRun 失败,代码仍然继续发送 artifact.published,节点留在内存/数据库中的状态仍是 running。
3. 平台没有对 PutRun 失败做节点级处理
internal/engine/run_state.go:
if err := e.repo.PutRun(r); err != nil {
log.Printf("put run %s: %v", id, err)
return false, err
}
调用方没有把这个错误转成节点失败或重试;Run 调度器看到节点仍是 running,就继续等待,形成永久卡死。
4. 僵尸节点没有看门狗
节点进程已经退出,但状态仍是 running,平台没有基于“无子进程 + 无新日志 + 超时”的看门狗把它标记为中断并重排。
Safety checks
- [x] I removed credentials, private endpoints, internal identifiers, and personal data.
- [x] I searched existing issues for duplicates.
感谢反馈。
我理解的情况是:节点产出的必需产物超过数据库字段上限后,产物写入失败,节点成功状态没有保存下来,整次 Run 会一直停在 running。
这条 Issue 已经看到,会按现有排期查看。
This looks like the same failure as #1092: the terminal node write is rejected with run_artifacts write: Error 1406 ... Data too long for column 'content' (run_artifacts.content is TEXT, 65,535 bytes), the node state never lands, and nothing reschedules a node that still reads running.
Fix pending in #1184: run_artifacts.content → MEDIUMTEXT with an idempotent manual migration, plus the terminal-write handling above (node becomes failed with the real cause instead of hanging). Could the run be checked with SELECT type, size_bytes FROM run_artifacts WHERE run_id=... to confirm the oversized artifact path?