Refactor method scheduling into ExecutionGroup#12
Open
mark1russell7 wants to merge 1 commit into
Open
Conversation
Splits method handling across three explicit owners: MethodInvoker is a
transport state machine (PENDING -> IN_FLIGHT -> WAITING_FOR_RESEND ->
COMPLETE/ABORTED) that consumes the retry budget at re-send time and
reports every terminal transition through a single onComplete delegate;
the new ExecutionGroup owns two-phase completion (result, updated, data
visibility) per group of methods, replacing the {wait, methods} blocks
and the global _methodsBlockingQuiescence map; the connection schedules
groups sequentially and merges old groups into new ones on reconnect,
preserving completion state.
Post-reconnect completion routing covers methods in any group (a method
whose result arrived before the drop can sit behind an onReconnect wait
method), teardown clears the queue before mass-aborting so nothing is
sent on a dead connection, and empty groups are reaped when advancing.
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
Refactors ddp-client's method scheduling into an explicit
ExecutionGroupmodel. This is the refactor half of #10, rebuilt on top of #11 (maxRetries) — it supersedes #10, which can be closed.Stacked on #11 (
feature/method-max-retries) — merge that first; this diff assumes it.Architecture
Three responsibilities, three owners (previously smeared across
MethodInvoker, the_outstandingMethodBlocksarray, and the global_methodsBlockingQuiescencemap):MethodInvoker— transport lifecycle of one method as an explicit state machine (PENDING → IN_FLIGHT → WAITING_FOR_RESEND → COMPLETE/ABORTED), including the retry budget (noRetry/maxRetries) consumed at re-send time. Every terminal transition reports to the connection through a singleonCompletedelegate — no matter how a method ends (completed, aborted on disconnect, retry budget exhausted), connection bookkeeping runs in exactly one place.ExecutionGroup(new) — owns the DDP two-phase completion protocol per group:resulttracking,updatedtracking (quiescence), data visibility, and deciding when each invoker's callback fires. Replaces the{wait, methods}block objects; "wait" methods become atomic groups.Connection— schedules groups sequentially (_methodQueue), advances when the leading group has fully delivered (reaping any groups emptied while queued), and merges old groups into new ones on reconnect with completion state preserved (transferMethod).Fixes over the #10 version
Review of #10 found three defects, all fixed here with regression tests:
updated/data-visibility routing to_methodQueue[0]— but after a reconnect merge, a method that received itsresultbefore the drop can sit in a later group (e.g. whenonReconnectqueues awaitlogin ahead of it). It would never complete — the exact hang class Fix DDP method hang on disconnect and null socket in Session.close() meteor/meteor#14193 fixes. All routing now finds the method's owning group, and the post-reconnect flush covers every group. Regression test: "result received before reconnect completes after onReconnect wait method".retry: falsemass-abort cleared nothing first, so completion bookkeeping would advance the queue andsendMessage()later groups mid-teardown. The queue is now cleared before aborting (same ordering Fix DDP method hang on disconnect and null socket in Session.close() meteor/meteor#14193 established). Regression test: "disconnect with retry false does not send queued methods".onCompletedelegate was passed but never wired, leaving three call sites each responsible for remembering manual cleanup. It's now the single notification path; the manual cleanup calls are gone.Also: retry exhaustion keeps #11's
invocation-failederror code (maxRetries: 0≡noRetry, unchanged error handling for callers), the asynconReconnectcallback support from release-3.5.1 is preserved (Promise.allSettledbefore re-sending), and the loud failure on anupdatedfor an unknown method is restored.Behavior notes
_outstandingMethodBlocks/block.waitare renamed to_methodQueue/group.atomic.Tests