Skip to content

The agent that grows with you

docs(cron): reap docstrings describe the live-owner stale bound

kshitijk4poorf4b403221126
diff --git a/cron/executions.py b/cron/executions.py
index 5a15946f77d..26836e2b7a2 100644
--- a/cron/executions.py
+++ b/cron/executions.py
@@ -318,7 +318,9 @@ _OWNER_WEDGED_REASON = (
def recover_interrupted_executions() -> int:
- """Mark provably abandoned attempts unknown without scheduling retries."""
+ """Mark abandoned attempts unknown without scheduling retries: rows whose owner is provably
+ dead, plus rows whose live owner holds a claim older than the derived stale bound (the
+ process is not killed)."""
now = _hermes_now().isoformat()
changed = 0
recovered: List[Dict[str, Any]] = []
diff --git a/cron/scheduler.py b/cron/scheduler.py
index 7cb3c2e43d3..997ebaf15a1 100644
--- a/cron/scheduler.py
+++ b/cron/scheduler.py
@@ -3755,8 +3755,9 @@ def _reap_throttle_key() -> str:
def _maybe_reap_dead_owners() -> None:
- """Dead-owner reclaim: a run that died mid-flight would leave its row 'claimed' forever. Only
- rows whose owner process is proved gone are touched (_owner_is_live). Throttled."""
+ """Dead-owner reclaim: a run that died mid-flight would leave its row 'claimed' forever. Rows
+ whose owner process is proved gone are released (_owner_is_live), as are rows whose live owner
+ holds a claim older than the derived stale bound (the process is not killed). Throttled."""
# Dead-owner claim reclaim (#86721): execution rows carry their owner pid + process start time, but
# recovery previously ran only at scheduler STARTUP. A one-shot `hermes cron run` that claimed a job and
# died mid-run (its runner thread lived in the exiting CLI process) left the row 'claimed' forever while
diff --git a/tools/cronjob_tools.py b/tools/cronjob_tools.py
index b158f89859d..51307c352f9 100644
--- a/tools/cronjob_tools.py
+++ b/tools/cronjob_tools.py
@@ -397,9 +397,9 @@ def _reap_stale_executions(job_name: str) -> None:
try:
# Reap any execution row this job (or any job) left stranded 'claimed'/ 'running' by a dead owner
# process -- e.g. a PRIOR one-shot `hermes cron run` invocation whose dispatched runner died with
- # the exiting process before writing a terminal status (issue #86721). Safe and cheap: only
- # provably-dead owners (PID gone, or PID reused by a different process per its start time) are
- # reaped; a genuinely live owner's row is left untouched.
+ # the exiting process before writing a terminal status (issue #86721). Safe and cheap: provably-dead
+ # owners (PID gone, or PID reused by a different process per its start time) are reaped, as is a
+ # live owner whose claim is older than the derived stale bound (the process itself is not killed).
from cron.executions import recover_interrupted_executions
_reclaimed = recover_interrupted_executions()
if _reclaimed: