Skip to content

fix: tolerate Cloro delivery gaps and refuse to stamp partial tracking runs - #649

Merged
gkhngyk merged 1 commit into
mainfrom
fix/tracking-run-stall-guard
Aug 5, 2026
Merged

gkhngyk merged 1 commit into
mainfrom
fix/tracking-run-stall-guard

Conversation

@gkhngyk

@gkhngyk gkhngyk commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

This morning's cron run for a production brand stamped with only 619 of 1,960 planned results, dragging the anchored 24h window — and the Daily Pulse mail — down to a visibility of 9 (real value ~14) and a "135 tracked prompts" reading (real: 279). Root cause from the logs and DB:

  • All 1,960 Cloro tasks were submitted successfully.
  • Cloro delivered ~600 results, then went quiet for 10+ minutes; the worker's stall guard (40 × 15s ≈ 10 min of no new results) gave up and stamped the run.
  • The remaining 1,058 results arrived minutes after the stamp — nothing was lost, but they fell outside the stamped window.

Two-part fix:

  1. Stall tolerance raised to ~25 min (stallPollLimit 40 → 100, env-overridable via CLORO_STALL_POLL_LIMIT). Cloro delivers in bursts with quiet gaps; the 60-min drain deadline remains the hard cap on a truly stuck queue.
  2. Partial-run stamp guard: a full run that produced fewer than 50% of its own planned task count is not stamped (row removed, warning logged) — the 24h anchor stays on the previous complete run, so the dashboard and pulse keep showing consistent full-run data instead of a half-empty window. The ratio compares against the run's own plan, never history, so legitimately shrinking a prompt set can't wedge the guard. Late results remain in the DB and surface in the next stamped window.

Related issue

None — production incident fix (diagnosed from today's cron run).

Type of change

  • fix — Bug fix

How to test

  1. Normal run: results ≥ 50% of planned tasks → stamped exactly as before (tracking run stamped log).
  2. Simulate partial delivery (or set CLORO_STALL_POLL_LIMIT=1 against a slow queue): run ends below the ratio → tracking run partial — below stamp ratio warning, no tracking_runs row, dashboard 24h window stays anchored to the previous complete run.
  3. Zero-result run behavior unchanged (row removed).

Checklist

  • Branch follows the naming convention (fix/)
  • Commits follow Conventional Commits
  • yarn lint passes (run from web/)
  • yarn typecheck passes (run from web/)
  • yarn format:check passes (run from web/)
  • Changes are focused — one concern per PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant