Skip to content

fix(pb): clean up actor stop decision handling#4566

Open
MasterPtato wants to merge 1 commit into04-06-fix_envoy_use_global_instance_add_signal_handlersfrom
04-06-fix_pb_clean_up_actor_stop_decision_handling
Open

fix(pb): clean up actor stop decision handling#4566
MasterPtato wants to merge 1 commit into04-06-fix_envoy_use_global_instance_add_signal_handlersfrom
04-06-fix_pb_clean_up_actor_stop_decision_handling

Conversation

@MasterPtato
Copy link
Copy Markdown
Contributor

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@MasterPtato MasterPtato requested a review from NathanFlurry April 6, 2026 19:54
Copy link
Copy Markdown
Contributor Author

MasterPtato commented Apr 6, 2026

@claude
Copy link
Copy Markdown

claude bot commented Apr 6, 2026

PR Review: fix(pb): clean up actor stop decision handling

Summary

This PR refactors the actor stop decision logic in runtime.rs from an imperative boolean-flag approach into a clean two-phase pattern: determine a Decision enum, then execute it. It also renames StoppedVariant::Normal to StoppedVariant::Stopped and makes minor cleanups to the test-envoy SSE handler and guard formatting.

The architectural direction is good, but there are a few issues worth addressing before merge.


High: SleepIntent with rewake_after_stop: false incorrectly maps to Reallocate

Both arms of the SleepIntent match map to Decision::Reallocate. In the old code, rewake_after_stop: false set try_reallocate = false, causing the actor to go to Sleeping. The new code unconditionally reallocates for both cases. The rewake_after_stop: false arm should map to Decision::Sleep instead.


Medium: SetSleepingInput now called during Reallocating without explanation

Previously SetSleepingInput was only invoked for Sleeping. Calling it also for Reallocating is a new side-effect with no explanation. If intentional (e.g., marking the actor as sleeping in the DB while awaiting retry), a short comment would help future readers.


Medium: Test-envoy no longer shuts down the envoy on SSE abort

The old code called envoy.shutdown(true) when the SSE client disconnected. The new code logs the abort but does not call shutdown. If a test client disconnects mid-run, the envoy process keeps running and could leak resources in the test environment.


Low: StoppedVariant::Lost implicit fall-through

Lost has no explicit arm in the new decision match and falls through to the crash policy arms. This is functionally correct, but a comment noting the intentional fall-through would aid readability.


Low: serverless-early-exit SSE event removed without explanation

The old handler sent a stopping SSE event when the shutdown reason was serverless-early-exit. The new polling handler removes this signal. If any consumer depended on it, this is a behavioral change worth calling out.


Positive Notes

  • The two-phase Decision enum approach is significantly cleaner than the original boolean-flag + nested match structure.
  • Renaming StoppedVariant::Normal to StoppedVariant::Stopped is a meaningful clarity improvement.
  • The Decision::Backoff path is now explicit where before it was buried in a catch-all branch.
  • Deduplication of the Reallocate execution path is a genuine win.

@MasterPtato MasterPtato force-pushed the 04-06-fix_pb_clean_up_actor_stop_decision_handling branch from 0c23581 to 9e8e9e5 Compare April 6, 2026 22:18
@MasterPtato MasterPtato force-pushed the 04-06-fix_envoy_use_global_instance_add_signal_handlers branch from 6c9af76 to 94f54ba Compare April 6, 2026 22:18
@MasterPtato MasterPtato mentioned this pull request Apr 6, 2026
11 tasks
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