Allow LAs to wake up workflow while another is still executing - #1442
Merged
Merged
Conversation
Sushisource
force-pushed
the
sj/fix-la-concurrent-resolution
branch
from
August 4, 2026 00:06
1bd838e to
478f379
Compare
Sushisource
marked this pull request as ready for review
August 4, 2026 00:06
Sushisource
force-pushed
the
sj/fix-la-concurrent-resolution
branch
from
August 4, 2026 17:29
a63386c to
d2a8ee4
Compare
Contributor
|
It looks like this PR also covers the bug that was addressed by #1075. Do you confirm? |
eamsden
requested changes
Aug 4, 2026
Member
Author
Yep & added tests |
eamsden
approved these changes
Aug 4, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What was changed
Live execution
Previously, when an activation scheduled local activities,
ManagedRunheld lang's activationcompletion response until every outstanding LA finished or the workflow task heartbeat fired. LA
results were applied internally, but lang could not poll another activation, so one long-running LA
could block a concurrent sequence of short LAs.
Core now acknowledges that activation completion with
DoNothingwhile keeping the WFT and itsheartbeat open. Each LA result is applied and immediately checked for a new activation, even while
other LAs remain outstanding:
LA result arrives -> apply result -> emit activation immediately -> lang schedules more workWhen the final LA finishes, Core completes the WFT normally with the accumulated marker commands.
Heartbeat completions request another WFT when LAs remain, and zero-sized-cache workers retain the
run until this process finishes.
The live LA state-machine path is unchanged:
Executing --Schedule--> RequestSent --HandleResult--> MarkerCommandCreated --CommandRecordMarker--> ResultNotified --MarkerRecorded--> MarkerCommandRecordedThe state machine already produced a resolution from
HandleResult; the live-path bug was thatManagedRunprevented that resolution activation from reaching lang while another LA was running.Replay compatibility
Incremental live delivery can create different activation groupings, so replay must reproduce the
order recorded by LA markers. Previously,
new_local_activitycould construct an LA directly inReplayingPreResolvedby looking up its sequence number, causing itsScheduletransition to emitthe resolution immediately. Results were therefore applied as activities were scheduled rather than
strictly in marker order.
Now every replaying LA starts unresolved and follows:
Replaying --Schedule--> WaitingResolveFromMarkerLookAhead --HandleKnownResult--> ResolvedFromMarkerLookAheadWaitingMarkerEvent --MarkerRecorded--> MarkerCommandRecordedworkflow_machines.rsretains peeked results in marker order in aVecDeque. After each workflowiteration, it supplies
HandleKnownResultfrom the front of that queue while the corresponding LAmachine exists, stopping at the first marker for an LA the workflow has not scheduled yet. The LA
state machine still owns one activity's lifecycle and validation;
workflow_machines.rsowns thecross-activity ordering needed to preserve activation boundaries.
This reproduces both old batched histories and new incrementally delivered histories without an SDK
compatibility flag. The old pre-resolved states and fake-marker plumbing are no longer needed.
Why?
This allows a sequence of short local activities to continue making progress while a long-running
local activity executes in parallel, without introducing nondeterminism when existing histories are
replayed.
Checklist
Closes: [Feature Request] Enable notifying lang in realtime of local activity resolutions #856 & [Bug] NDE replaying nested promises sdk-typescript#1744
How was this tested:
then fetched and replayed the generated history.
cargo test -p temporalio-sdk-core,cargo lint, andcargo test-lint.LocalActivityMachine_Coverage.puml.Any docs updates needed?
No. An Unreleased changelog entry is included.