fix(worker): 终态审计带上 error,复发卡死可定位
2026-10-29 任务 A:认领后 61 秒 interrupted,但终态审计只记 task_id、自动续跑又把 error_text 覆盖掉,事后无法区分取消、 配额、host 返回 interrupted 还是其它失败;容器 --rm 后日志 也没了,根因至今无法从留存证据证明(不是 sweep:阈值 300 秒;不是外部取消:该时段无取消审计;是 worker 自己写回 interrupted,但第一轮的 error 已被第二轮 failed 覆盖)。 本批不谎称找到根因,只补可定位性:run_one 终态审计在 interrupted/failed 时 detail 带 error(截 500 字、去换行), 完成态仍只记 task_id;分段审计 worker_exec_start/error/done 已在现 main,复发时最后一段 + 终态 error 即能定位。 单测 test_final_audit_detail_carries_error:失败派发后 worker_failed 审计 detail 以 'A:' 开头且含 error 文本。
This commit is contained in:
1 parent
b306b56517
commit
f4fb4000e1
2 files changed
+36
-1
No files matched your search
+11
-1
@@ -5025,12 +5025,22 @@ class Worker:
|
||||
if final_written:
|
||||
# 审计名须与终态一致:interrupted 任务记 worker_failed
|
||||
# 会把“可续跑的中断”误读成失败,误导后续排查。
|
||||
# 终态审计细节(2026-10-29 任务 A 教训):interrupted /
|
||||
# failed 时只记 task_id,事后完全无法区分是取消、
|
||||
# 配额、host 返回 interrupted 还是其它失败——且自动
|
||||
# 续跑会把 error_text 覆盖掉,第一轮的原因就此丢失。
|
||||
# 因此非完成终态的审计 detail 带上 error(截 500 字、
|
||||
# 去换行,不含 prompt/key),完成态仍只记 task_id。
|
||||
_final_detail = task_id
|
||||
if final in ("interrupted", "failed") and error:
|
||||
_final_detail = "%s: %s" % (
|
||||
task_id, str(error)[:500].replace("\n", " "))
|
||||
self._audit(task["project_id"],
|
||||
"worker_quota_stop" if quota_stop else
|
||||
("worker_completed" if final == "completed"
|
||||
else "worker_interrupted"
|
||||
if final == "interrupted"
|
||||
else "worker_failed"), task_id)
|
||||
else "worker_failed"), _final_detail)
|
||||
log_event(self.logger,
|
||||
"worker_quota_stop" if quota_stop else
|
||||
("worker_completed" if final == "completed"
|
||||
|
||||
Reference in new issue
Block a user