Skip to content

Align df.metrics() instance status counts with persisted df.instances (exclude rollback orphans)#217

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-rolled-back-executions-issues
Draft

Align df.metrics() instance status counts with persisted df.instances (exclude rollback orphans)#217
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-rolled-back-executions-issues

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown

df.metrics() could report higher failed_instances than df.instances/df.list_instances('failed') after rolled-back df.start() calls, because failures from orphan duroxide.executions rows were being counted as workflow failures. This changes metrics semantics to reflect persisted workflow instances for status counts.

  • Metrics source of truth

    • total_instances, running_instances, completed_instances, failed_instances now come from df.instances (persisted workflows).
    • total_executions and total_events continue to come from duroxide.executions / duroxide.history.
  • Query shape

    • Replaced Client::get_system_metrics() usage in df.metrics() with explicit SQL aggregation.
    • Uses a single scan over df.instances with FILTER (...) counts and cross-joins execution/event totals.
  • Regression coverage

    • Added an E2E regression in tests/e2e/sql/05_monitoring_and_explain.sql:
      • triggers a rolled-back df.start(),
      • waits for worker-side orphan failure effects to settle,
      • asserts df.metrics() instance counters match df.instances counters.
SELECT
  COUNT(*)::BIGINT AS total_instances,
  COUNT(*) FILTER (WHERE status = 'running')::BIGINT AS running_instances,
  COUNT(*) FILTER (WHERE status = 'completed')::BIGINT AS completed_instances,
  COUNT(*) FILTER (WHERE status = 'failed')::BIGINT AS failed_instances
FROM df.instances;

Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix rolled-back df.start() leaves failed duroxide.executions rows Align df.metrics() instance status counts with persisted df.instances (exclude rollback orphans) Jun 9, 2026
Copilot AI requested a review from pinodeca June 9, 2026 15:00
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.

Rolled-back df.start() leaves failed duroxide.executions rows that inflate df.metrics()

2 participants