Skip to content

docs: fence worker_functions row before deprecating workers in update guide - #670

Merged
jumski merged 1 commit into
mainfrom
issue-654-docs
Sep 4, 2026
Merged

docs: fence worker_functions row before deprecating workers in update guide#670
jumski merged 1 commit into
mainfrom
issue-654-docs

Conversation

@jumski

@jumski jumski commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rewrites the production Update Deployed Flows guide around a worker-function enable fence: record the current pgflow.worker_functions.enabled value, disable the row, deprecate its live workers, verify polling and in-flight work drained, deploy the replacement while the row stays disabled, restore the exact recorded value, and confirm the replacement worker reports a current heartbeat.
  • Adds failure guidance ("When the Drain or Restart Does Not Complete") with inspection SQL for workers that do not drain or restart.
  • Links the corrected sequence from the Worker Deprecation section of the Worker Management guide.

Every step ships copyable SQL: record enabled state, disable the function, deprecate workers, drain checks (heartbeat window + step_tasks leaving started), restore recorded state, replacement worker and heartbeat check.

Rationale: while the worker_functions row stays enabled, the ensure_workers() cron (1s interval) can start another instance of the old deployed function between deprecation and deployment, because deprecated workers do not count as alive for the restart check.

Per-step, alias-version, and shared-queue rollout instructions remain with #651, #648, and #652.

Checks

  • pnpm --filter @pgflow/website build passes (astro check clean, 135 pages, all internal links valid).
  • Schema claims cross-checked against pkgs/core/schemas/ (worker_functions, workers, ensure_workers, step_tasks) and worker runtime code.

Closes #654

… guide

The production Update Deployed Flows guide told operators to deprecate
old workers, deploy, and wait for cron. While the pgflow.worker_functions
row stays enabled, the ensure_workers() cron (1s interval) can start
another instance of the old deployed function between deprecation and
deployment, because deprecated workers do not count as alive for the
restart check.

Rewrite the guide around a disable fence for one worker function:

- record the current enabled value, then set enabled = false
- deprecate its live pgflow.workers rows
- verify polling stopped (heartbeat window) and in-flight work drained
  (step_tasks.status leaves 'started' for the deprecated workers)
- deploy the replacement while the row stays disabled
- restore the exact recorded enabled value, not an inferred one
- confirm the replacement worker reports a current heartbeat

Add failure guidance covering a worker that does not drain or does not
restart, with inspection SQL (worker listing, stuck task detail,
last_invoked_at, cron.job entry). Link the corrected sequence from the
Worker Deprecation section of the Worker Management guide.

Per-step, alias-version, and shared-queue rollout instructions stay with
issues #651, #648, and #652; deliberately not documented here.

Closes #654
@changeset-bot

changeset-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a1e54bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@nx-cloud

nx-cloud Bot commented Sep 4, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit a1e54bd

Command Status Duration Result
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded <1s View ↗
nx affected -t build --configuration=production... ✅ Succeeded <1s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 2s View ↗

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


☁️ Nx Cloud last updated this comment at 2026-09-04 20:41:12 UTC

Comment on lines +103 to +107
```sql "true"
UPDATE pgflow.worker_functions
SET enabled = true
WHERE function_name = 'your-worker-name';
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SQL example hardcodes enabled = true, but step 1 (line 35) instructs users to record and restore the exact original value, "even if it is false". Users who copy-paste this SQL will incorrectly enable an intentionally disabled function.

UPDATE pgflow.worker_functions
SET enabled = <recorded-value-from-step-1>
WHERE function_name = 'your-worker-name';

The example should use a placeholder like <recorded-value-from-step-1> or provide both cases explicitly, since this defeats the purpose of recording the value in step 1.

Suggested change
```sql "true"
UPDATE pgflow.worker_functions
SET enabled = true
WHERE function_name = 'your-worker-name';
```
```sql "<recorded-value-from-step-1>"
UPDATE pgflow.worker_functions
SET enabled = <recorded-value-from-step-1>
WHERE function_name = 'your-worker-name';
  

*Spotted by [Graphite](https://app.graphite.com/diamond/?org=pgflow-dev&ref=ai-review-comment)*<i class='graphite__hidden'><br /><br /><a href="https://app.graphite.com/github/pr/pgflow-dev/pgflow/670?chatWithGeneratedComment=ff8839d3-5940-4fe7-a2da-246ca18f8fd7"><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.graphite.dev/github-diamond-fix-in-graphite-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://static.graphite.dev/github-diamond-fix-in-graphite-light.svg"><img alt="Fix in Graphite" src="https://static.graphite.dev/github-diamond-fix-in-graphite-dark.svg"></picture></a></i><i class='graphite__hidden'><br /><br />Is this helpful? React 👍 or 👎 to let us know.</i>

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Preview Deployment: Website

Deployment successful!

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

📝 Details:

  • Branch: issue-654-docs
  • Commit: cb0cf9bf25ca9ccca84d61bfd71ab0b51563f390
  • View Logs

_Last updated: _

@jumski jumski left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all good - merge this pr using gt if it checks are green, then remove the current worktree and then close this issue workspace

---
title: Update Deployed Flows
description: Safe workflow for deploying flow updates to production using worker deprecation
description: Disable restarts, deprecate workers, drain, deploy, then re-enable to update deployed flows safely

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is user facing description - do you think its better now?

@jumski
jumski merged commit 99bef82 into main Sep 4, 2026
15 checks passed
@jumski
jumski deleted the issue-654-docs branch September 4, 2026 20:56
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

🚀 Production Deployment: Website

Successfully deployed to production!

🔗 Production URL: https://pgflow.dev

📝 Details:

  • Commit: 99bef82e0d3bd6271f1efe239aa4bc13c2e48a91
  • View Logs

Deployed at: 2026-09-04T22:55:22+02: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.

Document the worker-function enable fence for production deployments

1 participant