Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: graceful worker shutdown #2274

Conversation

MasterPtato
Copy link
Contributor

@MasterPtato MasterPtato commented Mar 26, 2025

Fixes RVT-4594

Changes

Copy link
Contributor Author

MasterPtato commented Mar 26, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link

cloudflare-workers-and-pages bot commented Mar 26, 2025

Deploying rivet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 580531f
Status: ✅  Deploy successful!
Preview URL: https://0fcd18b8.rivet.pages.dev
Branch Preview URL: https://03-26-feat-graceful-worker-s.rivet.pages.dev

View logs

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR implements graceful worker shutdown functionality across the workflow system, focusing on safe termination of running workflows and proper resource cleanup.

  • Added stop channel and check_stop() method in WorkflowCtx to enable interrupting workflows at any point during execution
  • Modified ListenCtx to use immutable reference to WorkflowCtx, improving signal handling during shutdown
  • Added shutdown sequence in worker.rs that waits for running workflows with timeout and handles SIGINT/SIGTERM
  • Implemented parallel execution using ctx.join in pegboard client workflow, replacing sequential operations that had deadlock issues
  • Added max_retries=15 for drain/undrain pegboard client activities to handle transient failures during shutdown

15 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

@MasterPtato MasterPtato force-pushed the 03-26-feat_graceful_worker_shutdown branch from d104e87 to f6a4e70 Compare March 26, 2025 19:39
@MasterPtato MasterPtato force-pushed the 03-25-feat_workflows_defererred_sqlite_tasks branch from 45c6cc6 to ceec131 Compare March 26, 2025 19:39
@MasterPtato MasterPtato force-pushed the 03-26-feat_graceful_worker_shutdown branch from f6a4e70 to eec0c12 Compare March 26, 2025 19:48
@MasterPtato MasterPtato force-pushed the 03-25-feat_workflows_defererred_sqlite_tasks branch from ceec131 to 4739210 Compare March 26, 2025 19:48
@MasterPtato MasterPtato force-pushed the 03-26-feat_graceful_worker_shutdown branch from eec0c12 to 9dcc276 Compare March 26, 2025 22:20
Copy link

linear bot commented Mar 26, 2025

@MasterPtato MasterPtato force-pushed the 03-25-feat_workflows_defererred_sqlite_tasks branch from 4739210 to 023537c Compare March 27, 2025 20:31
@MasterPtato MasterPtato force-pushed the 03-26-feat_graceful_worker_shutdown branch from 9dcc276 to 580531f Compare March 27, 2025 20:31
Copy link

Deploying rivet-hub with  Cloudflare Pages  Cloudflare Pages

Latest commit: 580531f
Status: ✅  Deploy successful!
Preview URL: https://eb1573f9.rivet-hub-7jb.pages.dev
Branch Preview URL: https://03-26-feat-graceful-worker-s.rivet-hub-7jb.pages.dev

View logs

Copy link
Contributor

graphite-app bot commented Mar 28, 2025

Merge activity

  • Mar 28, 2:55 PM EDT: MasterPtato added this pull request to the Graphite merge queue.
  • Mar 28, 2:56 PM EDT: CI is running for this pull request on a draft pull request (#2280) due to your merge queue CI optimization settings.
  • Mar 28, 2:57 PM EDT: A user merged this pull request with the Graphite merge queue via draft PR: #2280.

graphite-app bot pushed a commit that referenced this pull request Mar 28, 2025
<!-- Please make sure there is an issue that this PR is correlated to. -->
Fixes RVT-4594
## Changes

<!-- If there are frontend changes, please include screenshots. -->
@graphite-app graphite-app bot closed this Mar 28, 2025
@graphite-app graphite-app bot deleted the 03-26-feat_graceful_worker_shutdown branch March 28, 2025 18:57
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.

1 participant