Repository navigation
fix(workflow): wake all parents awaiting a shared child execution - #10885
Open
effect-bot wants to merge 10 commits into
Open
effect-bot wants to merge 10 commits into
effect-bot wants to merge 10 commits into
Conversation
🦋 Changeset detectedLatest commit: baea3c5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 40 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
…carded joins, and remote parents
…ization wake race
…n parent slot registration
This branch has not been deployed
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.
Summary
Wake every non-detached parent awaiting a shared child workflow execution across
ClusterWorkflowEngine,WorkflowEngine.layerMemory, andCloudflareWorkflowEngine.Previously, when multiple parent workflows executed the same child idempotency key (or joined a child started standalone), only one parent was recorded and woken when the child completed, leaving other waiting parents
Suspended.Changes
packages/effect/src/cluster/ClusterWorkflowEngine.ts):parentRPC keyed by consecutive index (String(index)) on workflow entities.run, stopping at the first slot returning the same parent (with primary-key deduplication acting as compare-and-set).registeredParentsscans consecutive slots (reading unprocessed messages as well as replies), merges therunpayload parent for backward compatibility, deduplicates, and wakes each parent viasendResumeParent.parentRPC with a defect,Effect.catchDefectstops probing immediately and falls back to the parent carried on therunpayload; replays reuse slot 0's cached defect reply instead of probing further indexes. New runners still read therunpayload parent so old-runner parents are woken alongside newly registered parents.packages/platform/cloudflare/src/internal/workflowStorage.ts,workflowRuntime.ts):workflow_parents (workflow_name, execution_id)table and insert non-detached parents synchronously inrunwhile the execution is incomplete.deliverParentWakewakes every remaining parent concurrently and deletes each row only once itsresumeis acknowledged. Unreachable parents stay inworkflow_parentsfor the guard alarm retry without blocking other parents or re-waking parents whose rows were already deleted.resume_pendingnow tracks only pending replays.parent_name/parent_execution_idcolumns on construction: copies intoworkflow_parentswhen incomplete or whenresume_pendingwas set on a completed execution, then nulls the legacy columns (and clearsresume_pendingif already complete).packages/effect/src/workflow/WorkflowEngine.ts):parentwith aSet<string>ofparents, adding every non-detached caller (including joins on existing executions) and waking all entries onComplete.effectand@effect/platform-cloudflare.Closes #10862
Closes EFF-4221
Co-authored-by: RhysSullivan [email protected]