worker: heartbeat parent task during marker poll/wait loops
Marker waits run after _run_attempt has cleared _running, so the run_loop heartbeat thread no longer refreshes the waiting parent. sweep_stale_tasks (default 300s) then kills a parent waiting up to the 3600s marker timeout, as seen in the marker live test (PM2 swept mid wait-threads). Poll and wait loops now heartbeat the parent each iteration (interval clamped to <=60s, well under the 300s threshold), best-effort, without touching _running, so no new capacity leak and cancel still works (empty _running entry has no proc/container to kill). Tests: 2 new sweep-survival tests (stale heartbeat at -299s, 2s wait, sweep must spare the parent); both fail 2/2 on pre-fix code and pass with the fix.
This commit is contained in:
1 parent
fd2309686e
commit
ccb22c960d
2 files changed
+133
No files matched your search
@@ -2402,6 +2402,15 @@ class Worker:
|
||||
if self._was_cancelled(task["id"]):
|
||||
cancelled = True
|
||||
break
|
||||
# 等候中父任务自己刷心跳:标记等待在 _run_attempt 返回后
|
||||
# 才跑,那时 _running 已被清掉,run_loop 的心跳线程刷
|
||||
# 不到它;不自刷的话,sweep(默认 300 秒)会在父任务
|
||||
# 等到 3600 秒上限之前把它当死任务误杀。每次循环刷一次,
|
||||
# 间隔至多 interval(钳制后 <=60 秒),远小于 300 秒阈值。
|
||||
try:
|
||||
self.heartbeat(task["id"])
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
conn = _db_connect(self.db_path)
|
||||
try:
|
||||
@@ -2450,6 +2459,12 @@ class Worker:
|
||||
if self._was_cancelled(task["id"]):
|
||||
cancelled = True
|
||||
break
|
||||
# 与 _poll_task_snapshot 同款:等候中父任务自己刷心跳,
|
||||
# 否则 sweep(默认 300 秒)会误杀最长可等 3600 秒的父任务。
|
||||
try:
|
||||
self.heartbeat(task["id"])
|
||||
except Exception:
|
||||
pass
|
||||
pending = [tid for tid in target_ids if tid not in resolved]
|
||||
if not pending:
|
||||
break
|
||||
|
||||
Reference in new issue
Block a user