Repository navigation
chore(orchestrator): Replace per-visit sweep logs with a heartbeat - #419
morgan-wowk wants to merge 1 commit into
Conversation
4ebb687 to
ac47a1e
Compare
| _logger.info( | ||
| f"Before processing running container execution. Queries duration {queries_duration_ms}ms." | ||
| ) | ||
| start_timestamp = time.monotonic_ns() |
There was a problem hiding this comment.
Is moving this start_timestamp here intentional and any beahviour changes?
There was a problem hiding this comment.
🤖 AI-assisted: Yes, intentional. start_timestamp used to be set before the execution-node-IDs query, so that query was counted in both queries_duration_ms and the processing duration. Setting it after the queries makes the two numbers in the slow-visit line separate, which tells a slow database apart from a slow launcher. No other behaviour changes: duration_ms only feeds that log line.
Also added in f0daa92: a once-a-minute heartbeat (Orchestrator heartbeat: processed N queued executions and M running container executions in the last 60s.). The per-visit lines we removed were the only sign the sweep was alive, so the heartbeat keeps that signal at one line a minute. If it stops appearing, the sweep has stopped.
The running queue visits every pending or running container execution round-robin, and each visit logged three INFO lines even when nothing changed. With hundreds of active executions that is tens of lines per second carrying no information. Drop the "Before processing", "After processing" and "remains in state" lines. Log one line only when a visit is slow: its queries or its processing take over 1s, matching the existing slow-query threshold for the idle queue log. The queries and processing times stay separate so a slow database is distinguishable from a slow launcher. Add a heartbeat line about once a minute from process_each_queue_once with the number of queued and running executions processed since the last one. The per-visit lines were the only sign that the sweep was still going; the heartbeat keeps that signal at one line a minute, and its absence means the sweep has stopped. State changes, terminations, retries and errors keep their existing logs.
ac47a1e to
f0daa92
Compare
Changes
The running queue visits every pending or running container execution in turn, and each visit logged three INFO lines even when nothing changed:
Before processing running container execution. Queries duration …ms.Container execution remains in RUNNING state.After processing running container execution (duration: …ms)This PR removes all three and adds two lines that only appear when they carry information:
Slow running container execution visit (queries: …ms, processing: …ms)The 1000ms threshold matches the one the idle-queue log already uses. The queries time covers the select that picks the next execution plus the execution-node lookup. The processing time covers the refresh. Keeping them apart separates a slow database from a slow launcher.
process_each_queue_once:Orchestrator heartbeat: processed 12 queued executions and 1840 running container executions in the last 60s.It's logged even when both queues are idle, and only by the orchestrator that is actually sweeping.
Impact
Container execution is now in state …), terminations, cancellations, retriable refresh failures and exceptions.query_duration_mslog doesn't cover. Theorchestrator.process_running_executiontrace span is unchanged.Before / after (500 active executions, steady state, one minute)
Before: about 3 lines per visit, so thousands of INFO lines.
After: 1 heartbeat line, plus one line per slow visit or state change.
Testing
pytest tests: 576 passed. New tests:TestHeartbeatcovers an idle heartbeat after the interval, and counts that reset between heartbeats.🤖 Generated with Claude Code