Repository navigation
Deliver cluster WithTransaction replies after the transaction outcome is known - #8891
Merged
Merged
Conversation
…ion outcome Red regression tests for EFF-1823; the implementation follows on this branch.
…utcome is known Hold the caller delivery of a persisted request's WithExit reply until COMMIT, defer processed/active bookkeeping until the transaction exits, and replay the request when COMMIT or ROLLBACK fails instead of sending a reply.
🦋 Changeset detectedLatest commit: 456aae6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 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 |
…defect replay A fatal defect inside the transaction forks the restart with the request's HeldReply in context, so the replayed attempt's post-rollback failure reply is held in a stale holder and never reaches the caller. Red until the fix lands.
…r attempts A holder closes when its transaction exits, so replies saved later (a post-rollback failure, a late Deferred reply) are delivered immediately. Restarts and uninterruptible re-writes no longer fork with the current transaction's hold, so replayed handlers never start with a stale one.
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
The reply hold is now provided to storage only around the single saveReply call the entity manager makes inside the transaction, so no handler, replay or Deferred fiber can inherit it. Settlement is one step keyed on the transaction outcome, and wrapper-only COMMIT/ROLLBACK failures are detected with Cause equality.
…ansaction MessageStorage.make.withTransaction now collects the caller notifications of WithExit replies saved inside it and runs them after the driver transaction commits, so the entity manager no longer carries a reply hold. The entity manager only records how a persisted reply settles once the transaction outcome is known, and restart and re-write forks leave the dying handler's context behind instead of inheriting it. The rollback test storage wraps the memory driver's transaction, where COMMIT and ROLLBACK actually run.
…ctions Reply handlers must learn of a WithExit reply saved in a nested MessageStorage transaction only when the outermost transaction commits, and not at all when the outer transaction fails or the inner one rolls back.
…t was reported as failed A persisted WithTransaction request must not be replayed once its COMMIT has applied, whether the wrapper then reports an interrupt or a failure. With a driver that rejects a second WithExit reply, like the SQL tables do, the replay's save fails and the entity restarts again.
…s misreported Mask interrupts around the request transaction, restoring them only for the handler, so an interrupt during COMMIT no longer hides a committed outcome. When a successful handler's transaction still reports a failure, check storage for its terminal reply before replaying: if it exists the COMMIT applied, so complete the request and release callers to read the stored reply.
… rollback regressions
Merged
2 of 5 tasks
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.
Follow-up to #8886. A persisted
ClusterSchema.WithTransactionrequest no longer shows anything to its caller before the transaction outcome is known.Before this change, the reply-handler layer in
MessageStorage.makedelivered a success to callers while the transaction was still open, andentityManagermarked the request processed inside the transaction. If COMMIT then failed, the caller already had a success and the request stayed unprocessed in storage until a restart. #8886 also sent the held failure reply when ROLLBACK died, with no proof that the database rolled back.Changes
MessageStorage.make.withTransactioncollects the caller notifications ofWithExitreplies saved inside it and runs them once the driver transaction has committed.saveReplystill saves inside the transaction; only the notification moves. The context reference that carries the pending notifications is private toMessageStorage.ts. Chunks are always delivered immediately. The publicMessageStoragesignatures are unchanged.entityManagerhas no notion of a reply hold. For a persistedWithTransactionrequest it records onesettlestep and runs it with the transaction's exit: committed → bookkeeping (storage already notified the caller); clean rollback after a handler failure → save and deliver the failure, as in Persist cluster WithTransaction failure replies after rollback #8886; COMMIT or ROLLBACK died, detected as the wrapper's cause not equalling the handler's → rebuild and replay throughrestartFrom, shared withDefect.WithTransactionrequests use the bare storage transaction, as before Persist cluster WithTransaction failure replies after rollback #8886. Their replies are not saved, so there is nothing to wait for.ClusterSchema.WithTransactionandMessageStorage.withTransactionstate the invariant and its three exclusions: stream chunks, handlers that return aDeferred, and non-persisted requests.effectpatch changeset.The rollback test storage now wraps the memory driver's transaction via
MessageStorage.makeEncoded, which is where a real COMMIT or ROLLBACK fails, rather than wrapping the public service above the reply layer. The #8886 rollback test uses the same helper.Out of scope, as planned in the parent issue: BEGIN failure, retries inside an aborted transaction, and real-database integration coverage.
Validation
packages/effect/test/cluster/Sharding.test.ts: 81/81 pass, including the four regression tests and the existing propagation, rollback-failure reply and caller-bound ordering testspackages/effect/test/clusterandpackages/effect/test/rpc: 18 files, 295/295 passpackages/platform/nodetest/cluster/SocketRunner.test.tsandtest/RpcServer.test.ts: 109/109 pass. The Docker-backed integration suites gated onEFFECT_CLUSTER_TESTS=1were not run.pnpm lint,pnpm checkandpnpm jsdocs --checkpassCloses EFF-1823
Closes EFF-1835
Closes EFF-1836