The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): key the store-unwritable rate limit by store, and name the store
kshitijk4poorc1d8f59f0019
diff --git a/cron/jobs.py b/cron/jobs.pyindex 16535140e21..131936e9241 100644--- a/cron/jobs.py+++ b/cron/jobs.py@@ -1247,7 +1247,7 @@ def _write_marker(name: str, text: str, tmp_prefix: str) -> None:pass-# One WARNING per errno per window: an unwritable store fails every 60s tick until fixed.+# One WARNING per (store, errno) per window: an unwritable store fails every 60s tick until fixed._STORE_WARN_INTERVAL_SECONDS = 900.0_last_store_warning: dict = {}@@ -1255,14 +1255,15 @@ _last_store_warning: dict = {}def warn_store_unwritable(exc: OSError, consequence: str) -> None:"""Rate-limited WARNING for a failed cron store write (ENOSPC/EROFS/EACCES). Callers skip thedispatch that needed the write: no job runs without a durable advance/fire claim."""- now, key = time.monotonic(), exc.errno+ cron_dir = str(_current_cron_store().cron_dir) # multi-profile gateway: one key per store+ now, key = time.monotonic(), (cron_dir, exc.errno)last = _last_store_warning.get(key)if last is not None and now - last < _STORE_WARN_INTERVAL_SECONDS:return_last_store_warning[key] = nowlogger.warning(- "Cron store is unwritable (%s); %s. Jobs stay due and fire once the store accepts writes "- "again.", exc, consequence)+ "Cron store %s is unwritable (%s); %s. Jobs stay due and fire once the store accepts writes "+ "again.", cron_dir, exc, consequence)def record_ticker_heartbeat(success: bool = False) -> None:diff --git a/tests/cron/test_due_scan_save_failure.py b/tests/cron/test_due_scan_save_failure.pyindex b898979c131..e4d603f5856 100644--- a/tests/cron/test_due_scan_save_failure.py+++ b/tests/cron/test_due_scan_save_failure.py@@ -80,9 +80,14 @@ def test_due_jobs_are_returned_when_the_store_cannot_be_saved(cron_store, full_dassert [d["id"] for d in get_due_jobs()] == ["due-job"]assert [d["id"] for d in get_due_jobs()] == ["due-job"]- # Rate-limited like the tick-level skips: one WARNING per outage, not one per 60s scan.+ with cronjobs.use_cron_store(cron_store / "other-profile"): # a second profile's store+ cronjobs.warn_store_unwritable(OSError(errno.ENOSPC, "No space left on device"), "x")++ # Rate-limited per store: one WARNING per outage per profile, not one per 60s scan, and a+ # sibling profile on the same errno is not silenced; each names its store.warnings = [r.getMessage() for r in caplog.records if r.name == "cron.jobs" and r.levelno == logging.WARNING]- assert len(warnings) == 1 and "due-scan repairs not persisted" in warnings[0]+ assert len(warnings) == 2 and "due-scan repairs not persisted" in warnings[0]+ assert str(cron_store / "cron") in warnings[0] and str(cron_store / "other-profile") in warnings[1]def test_tick_on_unwritable_store_returns_cleanly_without_dispatch(cron_store, monkeypatch, caplog):@@ -109,7 +114,7 @@ def test_tick_on_unwritable_store_returns_cleanly_without_dispatch(cron_store, massert scheduler.tick(verbose=False, sync=True) == 0assert ran == []- assert "Cron store is unwritable" in caplog.text+ assert f"Cron store {cron_store / 'cron'} is unwritable" in caplog.textassert load_jobs() == beforerow = executions.latest_execution("once")assert row["status"] == "failed" and "Cron store unwritable" in row["error"]