Skip to content

Conversation

@jumski
Copy link
Contributor

@jumski jumski commented Dec 4, 2025

Add mark_worker_stopped function for graceful worker shutdown

This PR adds a new SQL function pgflow.mark_worker_stopped(worker_id) that sets the stopped_at timestamp on a worker row to signal a graceful shutdown. This function will be called by workers during the beforeunload event.

The changes include:

  • New SQL function definition in pkgs/core/schemas/0058_function_mark_worker_stopped.sql
  • Migration file to add the function to the database
  • TypeScript type definition for the function in database-types.ts
  • Test case to verify the function correctly sets the stopped_at timestamp

This functionality enables workers to signal when they're shutting down, which will help with proper resource cleanup and task reassignment.

@changeset-bot
Copy link

changeset-bot bot commented Dec 4, 2025

⚠️ No Changeset found

Latest commit: 5813d23

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

Copy link
Contributor Author

jumski commented Dec 4, 2025

@nx-cloud
Copy link

nx-cloud bot commented Dec 4, 2025

View your CI Pipeline Execution ↗ for commit 5813d23

Command Status Duration Result
nx run edge-worker:test:integration ✅ Succeeded 3m 44s View ↗
nx affected -t verify-exports --base=origin/mai... ✅ Succeeded 3s View ↗
nx affected -t build --configuration=production... ✅ Succeeded 22s View ↗
nx affected -t lint typecheck test --parallel -... ✅ Succeeded 1m 38s View ↗
nx run client:e2e ✅ Succeeded 1m 9s View ↗
nx run cli:e2e ✅ Succeeded 3s View ↗
nx run edge-worker:e2e ✅ Succeeded 44s View ↗
nx run core:pgtap ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-08 08:49:54 UTC

@jumski jumski force-pushed the 12-04-add_track_worker_function_sql_function_for_worker_registration branch from 179a131 to a6b7275 Compare December 4, 2025 16:54
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from ab375be to db727ea Compare December 4, 2025 16:54
@jumski jumski changed the base branch from 12-04-add_track_worker_function_sql_function_for_worker_registration to graphite-base/506 December 5, 2025 07:20
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from db727ea to dbb4e58 Compare December 5, 2025 07:21
@jumski jumski force-pushed the graphite-base/506 branch from a6b7275 to a26dc00 Compare December 5, 2025 07:21
@jumski jumski changed the base branch from graphite-base/506 to 12-04-add_track_worker_function_sql_function_for_worker_registration December 5, 2025 07:21
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from dbb4e58 to e6d1032 Compare December 5, 2025 09:24
@jumski jumski force-pushed the 12-04-add_track_worker_function_sql_function_for_worker_registration branch 2 times, most recently from bfe384c to 89d0e0b Compare December 5, 2025 10:04
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from e6d1032 to 8e3510f Compare December 5, 2025 10:04
@jumski jumski force-pushed the 12-04-add_track_worker_function_sql_function_for_worker_registration branch from 89d0e0b to 5e801eb Compare December 5, 2025 13:05
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from 8e3510f to 404fa0c Compare December 5, 2025 13:05
@jumski jumski force-pushed the 12-04-add_track_worker_function_sql_function_for_worker_registration branch from 5e801eb to aedf84f Compare December 5, 2025 22:53
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from 404fa0c to 389d7b8 Compare December 5, 2025 22:53
@jumski jumski force-pushed the 12-04-add_track_worker_function_sql_function_for_worker_registration branch from aedf84f to 9d5e568 Compare December 7, 2025 16:45
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from 389d7b8 to 0de2c9a Compare December 7, 2025 16:45
@jumski jumski force-pushed the 12-04-add_track_worker_function_sql_function_for_worker_registration branch from 9d5e568 to ede8125 Compare December 8, 2025 05:23
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from 0de2c9a to 7f0069f Compare December 8, 2025 05:23
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🔍 Preview Deployment: Website

Deployment successful!

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

📝 Details:

  • Branch: 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling
  • Commit: 9ac7e12859edfcc347c19ed3102aceee4bf67481
  • View Logs

_Last updated: _

Copy link
Contributor Author

jumski commented Dec 8, 2025

Merge activity

  • Dec 8, 8:07 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Dec 8, 8:43 AM UTC: Graphite rebased this pull request as part of a merge.
  • Dec 8, 8:50 AM UTC: @jumski merged this pull request with Graphite.

@jumski jumski changed the base branch from 12-04-add_track_worker_function_sql_function_for_worker_registration to graphite-base/506 December 8, 2025 08:34
@jumski jumski changed the base branch from graphite-base/506 to main December 8, 2025 08:41
@jumski jumski force-pushed the 12-04-add_mark_worker_stopped_sql_function_for_graceful_shutdown_signaling branch from 7f0069f to 5813d23 Compare December 8, 2025 08:42
@jumski jumski merged commit b388578 into main Dec 8, 2025
11 of 13 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

🚀 Production Deployment: Website

Successfully deployed to production!

🔗 Production URL: https://pgflow.dev

📝 Details:

  • Commit: b3885786a2acc6f4f0cd99cc9f6bb7e0e14d8a5e
  • View Logs

Deployed at: 2025-12-08T09:50:32+01: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.

2 participants