Skip to content

bug(timeline): CB probe executions left open until backend restart inflate failure duration on timeline #767

Description

@vybe

Summary

When the circuit breaker fires probes against an agent, each probe creates a schedule_executions record. If the probe is rejected (CB open), the record is never closed — it stays in a non-terminal state until the next backend restart, which runs startup cleanup and marks it failed. The result is a large red block on the execution timeline spanning the entire window from probe creation to backend restart, giving a misleading picture of agent activity.

Component

Backend / Circuit Breaker / Execution Timeline (Frontend)

Priority

P3

Observed Behavior

  1. Circuit breaker opens for an agent
  2. CB fires probe executions — each creates a schedule_executions row
  3. Probes are rejected (CB open), but their DB records are never closed
  4. Records sit in non-terminal state (running, pending_retry, etc.)
  5. On next backend restart, startup cleanup closes them with error = "Execution orphaned — recovered on backend restart"
  6. completed_at is set to the restart time, not the actual probe end time
  7. Timeline displays a large red failure block spanning the full gap (e.g. 40 minutes) instead of a brief probe event

Root Cause

CB probe executions are not closed at the point of rejection. The backend creates the execution record before dispatching to the agent, but when the CB rejects the call, no corresponding completed_at / failed update is written back to schedule_executions. The record is only resolved as a side-effect of backend restart orphan cleanup, which stamps the current wall-clock time as completed_at — not the actual failure time.

Reproduction Steps

  1. Trigger enough consecutive agent failures to open the circuit breaker
  2. Observe CB firing probe executions in scheduler logs
  3. Let the CB remain open for several minutes without a backend restart
  4. Check schedule_executions — probe records will be in non-terminal state
  5. Restart the backend
  6. View the agent's execution timeline — probe records now show as long-duration failures

Suggested Fix

When the circuit breaker rejects a call, immediately close the associated execution record with status = 'failed', completed_at = now(), and a descriptive error such as "Rejected by circuit breaker (open state)". This ensures the timeline accurately reflects a brief probe attempt rather than a multi-minute failure span.

Alternatively, CB probe executions could be marked with a distinct status (e.g. cb_rejected) so the frontend can render them differently (e.g. as a small marker rather than a full red block).

Related

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions