You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
This PR fixes a real bug in the allocate activity in actor2/runtime.rs. Previously, SleepTsKey was deleted unconditionally at the start of every allocation attempt — even when the allocation failed (e.g., due to ConcurrentActorLimitReached or NoEnvoys). Now the deletion is gated on a successful allocation (allocation.is_some()). The fix is correct and minimal.
What the Bug Was
Before this change, the following was placed unconditionally inside the FDB transaction before any allocation decision was made:
// Set not sleeping
tx.delete(&keys::actor::SleepTsKey::new(actor_id));
This meant that a sleeping actor that failed to allocate (no envoys available, concurrent actor limit reached) would have its SleepTsKey deleted and state.sleep_ts cleared — even though the actor remained in a sleeping/reallocating state. This could cause the gateway (ops/actor/get_for_gateway.rs) to report sleeping: false for an actor that was actually still sleeping, potentially preventing proper wake-on-request behavior.
After the fix, tx.delete and state.sleep_ts = None are only executed when allocation.is_some().
Correctness Analysis
The fix is logically sound. The set_sleeping activity writes SleepTsKey and sets state.sleep_ts = Some(now). The only correct time to clear them is when the actor is actually being woken up, which requires a successful allocation. The v1 actor workflow in actor/runtime.rs correctly gates its SleepTsKey deletion inside the allocated-status branch, consistent with this fix.
Both the UDB key deletion and state.sleep_ts = None are correctly gated together on allocation.is_some(), keeping the FDB key and in-memory state in sync.
Potential Concerns
1. No regression test added
The PR does not add a test for this scenario. A test covering "sleeping actor fails to allocate, sleep_ts remains set" would prevent regressions. Non-blocking given existing test infrastructure, but worth a follow-up.
2. PR description is unfilled
The PR body does not describe what the bug was, what caused it, or how it was found/tested. A short description of the scenario would help with future archeology.
Code Style
No issues. Logging follows tracing::* structured-field convention, no println!/eprintln! introduced, comment style matches surrounding code, hard tabs used correctly.
Verdict
Approve. The fix is correct, minimal, and matches the pattern used in the v1 actor workflow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: