Repository navigation
Answer fresh local cluster requests without a storage readback - #9336
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: e1a1da3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 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.
|
Register a storage waiter with the reply loop from `replyFromStorage` instead of the pump's first pass. The entry no longer carries a mutable `readNow` flag, `readStorageRequest` goes away, and a waiter that joins an entry is in its message set before any immediate read runs, so it receives the reply as well. A dropped reply handler is now observed with `Fiber.join`, so a handler interrupted during shutdown propagates the abandon interrupt to the caller as the storage-read path already did.
tim-smart
reviewed
Oct 16, 2026
| message: Message.OutgoingRequest<any>, | ||
| notifyEntity: (message: Message.Outgoing<any>) => Effect.Effect<void> | ||
| ) => | ||
| Effect.gen(function*() { |
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.
In 4.0.5,
Runners.notifyLocalstarted reading every local reply back from storage, as part of the fix for lost replies in #9175. That added a SQL round trip to every reply of a locally owned request. This PR brings back direct local delivery for fresh requests and keeps the #9175 fix.Change
For a persisted, non-stream request that isn't discarded and whose entity is on a local shard:
saveRequest. The request can be processed as soon as it is saved, so registering first closes the cluster: a local persisted request can wait forever when its reply is saved beforeregisterReplyHandler(Runners.notifyLocal) #9175 race: no reply can be saved before the handler exists. A fresh request gets its reply from the handler, with no storage read and no polling.registerReplyHandlerregistering as soon as its effect starts. Every storage built withMessageStorage.makealready does, andClusterWorkflowEngine.awaitRunReplyandRunnerServeralready depend on it. The contract is now documented onMessageStorage.registerReplyHandler. A storage wrapper that suspends before registering, like the one in the cluster: a local persisted request can wait forever when its reply is saved beforeregisterReplyHandler(Runners.notifyLocal) #9175 reproduction, is not supported.EntityNotAssignedToRunner, for example when a shard moves or a commit error hides the notification), the request reads storage straight away. 4.0.4 did this; 4.0.5 waited forentityReplyPollInterval. A shutdown abandon interrupt still propagates to the caller.Stream requests and requests for entities on other runners stay on the storage loop, so chunk ordering and acks don't change. Terminal replies still notify at the outer commit (
TransactionNotifications), so the commit boundary holds.Tests
The new tests in
packages/effect/test/cluster/Runners.test.ts:The two #9175 tests still pass, including the reply saved before
saveRequestreturns; both fail with the 4.0.4Runners.ts.The
cluster,workflowandplatform-nodesuites pass (744 tests; the cluster suite passed 3 more repeated runs),pnpm checkis clean, and lint is clean on the changed files.On a Postgres workload (30 concurrent parent workflows with activity chains, children and externally completed deferreds), a prototype of this handler-first path issued 2
repliesForqueries, against about 430 to 530 on 4.0.5. Parent runs were 84, against 85 to 88 with the 4.0.4Runners.ts. I haven't re-measured the final commit.Replay amplification is not confirmed
I could not reproduce the doubled workflow replays from #9335. In-memory runs with injected reply latency, and Postgres runs, showed the same or slightly fewer replays on 4.0.5 than on 4.0.4. This PR removes the per-reply storage round trip for local requests, which the issue identifies as the change that matters. Whether that also brings the reporter's replay counts back down still needs confirming on their workload.
Closes #9335
Closes EFF-2308