Skip to content

Skip paths archive sibling messages but never terminalize sibling step_tasks rows, leaving status='started' tasks on completed runs - #649

Merged
jumski merged 1 commit into
mainfrom
issue-638-terminalize-skipped-tasks
Aug 28, 2026
Merged

Skip paths archive sibling messages but never terminalize sibling step_tasks rows, leaving status='started' tasks on completed runs#649
jumski merged 1 commit into
mainfrom
issue-638-terminalize-skipped-tasks

Conversation

@jumski

@jumski jumski commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add skipped as a terminal step_tasks.status value.
  • Terminalize queued and started task rows when fail_task or _cascade_force_skip_steps skips their parent step, while preserving message archival, events, counters, callbacks, and return values.
  • Backfill existing active task rows under skipped steps, document the status, and add an @pgflow/core patch changeset.

Checks

  • Six focused pgTAP regression files pass: 40 assertions total.
  • pnpm nx verify-migrations core --skip-nx-cache
  • pnpm nx gen-types core --skip-nx-cache with no generated type diff
  • pnpm nx verify-gen-types core --skip-nx-cache
  • pnpm nx test:pgtap core --skip-nx-cache — 279 files, 1,259 tests
  • Migration backfill fixture — failed, completed, started, queued becomes failed, completed, skipped, skipped
  • /usr/bin/git diff-tree --check HEAD^ HEAD

pnpm nx fix-sql core hits the existing local toolchain error sqruff: error: unexpected argument '--force' found; direct Sqruff formatting reported no changes.

Closes #638

@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 10e698a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@pgflow/core Patch
pgflow Patch
@pgflow/client Patch
@pgflow/edge-worker Patch
@pgflow/dsl Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

jumski commented Aug 21, 2026

Copy link
Copy Markdown
Contributor Author

@jumski jumski changed the title fix(core): terminalize skipped tasks Skip paths archive sibling messages but never terminalize sibling step_tasks rows, leaving status='started' tasks on completed runs Aug 21, 2026
@nx-cloud

nx-cloud Bot commented Aug 21, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a9045de

Command Status Duration Result
nx run edge-worker:e2e ✅ Succeeded 7m 40s View ↗
nx run edge-worker:test:integration ✅ Succeeded 4m 24s View ↗
nx run client:e2e ✅ Succeeded 1m 15s View ↗
nx run edge-worker:e2e:portable-runtimes ✅ Succeeded 55s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 4s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 3s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 25s View ↗
Additional runs (2) ✅ Succeeded ... View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-28 07:19:30 UTC

jumski commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Aug 28, 7:08 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 28, 7:09 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 28, 7:20 AM UTC: @jumski merged this pull request with Graphite.

Skip paths archived sibling queue messages but left their step_tasks rows queued/started, so completed runs carried active task rows (#638).

fail_task and _cascade_force_skip_steps now terminalize active sibling tasks first via UPDATE ... RETURNING capturing message_ids, then archive only those ids. This enforces step_tasks-before-PGMQ lock order and fixes a reproduced deadlock against requeue_stalled_tasks, which locks task rows before queue rows.

start_tasks returned pre-update candidates; when a concurrent skip won the task-row lock, the guarded UPDATE claimed zero rows yet start_tasks still returned the task, so workers executed skipped handlers. The tasks CTE is now the UPDATE ... RETURNING itself; all downstream CTEs and the result consume only claimed rows.

Rejected alternative: joining the guarded update by run_id+step_slug+task_index produced a quadratic plan (~20s with 10k map tasks). Kept the indexed message_id+flow_slug+status='queued' predicate (max ~6ms).

Migration regenerated as 20260827180017_pgflow_terminalize_skipped_tasks.sql: adds 'skipped' to valid_status, installs both functions, and backfills orphaned active tasks under skipped steps (failed-run rows out of scope, #645).

Tests: returns_only_claimed_tasks.test.sql (suppressed-claim regression), queue-order trigger in skip_archives_sibling_messages.test.sql; full suite 280 files / 1262 assertions pass.
@jumski
jumski force-pushed the issue-638-terminalize-skipped-tasks branch from a9045de to 10e698a Compare August 28, 2026 07:08
@jumski
jumski merged commit daadcac into main Aug 28, 2026
15 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Production Deployment: Website

Successfully deployed to production!

🔗 Production URL: https://pgflow.dev

📝 Details:

  • Commit: daadcac754ab3fdea1bdd251650e6e9567ed4545
  • View Logs

Deployed at: 2026-08-28T09:20:29+02:00

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Preview Deployment: Website

Deployment successful!

🔗 Preview URL: https://pr-649.pgflow.pages.dev

📝 Details:

  • Branch: issue-638-terminalize-skipped-tasks
  • Commit: c0d792525ecbbec5c68b6218d1cba4da88f86e43
  • View Logs

_Last updated: _

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.

Skip paths archive sibling messages but never terminalize sibling step_tasks rows, leaving status='started' tasks on completed runs

1 participant