ExportXMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Cluster Scalability
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Motivation
      The recipient’s rules so far look only at its persisted document. Some failure modes are about state that is not in the document: whether a promise that another component waits on has been settled, and whether the change-streams monitor is running. These matter because, the coordinator sends commands to the recipient and waits for the reply, so a promise that never settles would stall the whole operation, and a recipient that recovers after a failover infers some decisions from the document alone. The technical design (WRITING-40550) says the state machine re-checks promise fulfilment at transitions; the donor already does (resharding_donor_service.cpp:1332). The recipient does not.

      Context

      The following table lists every runtime fact the recipient holds and the dependent component for each transition as well as the consequences if violated.

        Condition Dependent Component Violation Consequence Code ref
      1 The change-streams monitor is running when verification is on The coordinator's check of the final data before it commits The coordinator waits until its verification deadline inside the critical section, skips verification and commits anyway. Writes stay blocked longer and verification is silently lost. fetch-final-stats command waits for the monitor, line 76; verification skipped at the deadline, line 1936
      2 A recipient that finishes without an abort reason was really committed Recovery after a failover, which decides "committed" from the absence of an abort reason An aborted operation is recovered as if it had committed. _recoverCoordinatorCommitted, line 150
      3 The "in creating collection" promise is settled once the recipient creates its collection The clone command, which waits on that promise. The coordinator sends it when it enters cloning. The command never returns and the operation is stuck in cloning. clone command waits on the promise, line 83
      4 The "in strict consistency or error" promise is settled once the recipient reaches strict consistency The critical-section-started command, which waits on that promise. The coordinator sends it when it enters blocking writes. The command never returns and the coordinator is stuck before it can wait for the recipients. critical-section-started command waits on the promise, line 75
      5 When the recipient moves to error, the promises others wait on are settled The same two commands as in rows 3 and 4 The commands block forever and the coordinator can't send the abort that would release them. The worst case is an error before the collection is created. clone command, line 83; critical-section-started command, line 75; onRecipientStateAdvanced, line 71; setRecipientError, line 44

       

      Proposed approach
      Add a facts struct to the pre- and post-check inputs, filled by one function (_gatherTransitionFacts as on the donor) under _mutex (the donor's has the same shape).

      Read the following facts as follows:

      • The inCreatingCollection, inStrictConsistencyOrError and coordinatorCommitted promises: three states (pending, fulfilled or rejected).
      • Whether the change-streams monitor has started: the _changeStreamsMonitorStarted promise, ready and successful. Never read the _changeStreamsMonitor pointer, which is assigned without _mutex.
      • Whether the recipient is stepping down: _cancelState.isSteppingDown(). It is used only to suppress committedUnlessAbortReason, never as a condition.

      Gather the pre-check’s facts at the pre-check call, before the write (SERVER-139806), and the post-check’s facts after the lock scope that fulfils the promises (see the notes). Then add these constraints:

      Constraint Transition Kind   Violation Point
      changeStreamsMonitorStartedIfVerifying kApplying to kStrictConsistency pre performVerification is set, skipCloningAndApplying is not, and the monitor has not started
      committedUnlessAbortReason any transition to kDone pre the proposed context has no abort reason, coordinatorCommitted is not fulfilled, and the recipient is not stepping down
      inCreatingCollectionSettled kAwaitingFetchTimestamp to kCreatingCollection post inCreatingCollection is still pending
      inStrictConsistencyOrErrorSettled kApplying to kStrictConsistency post inStrictConsistencyOrError is still pending
      waitedOnPromisesSettled each of the five transitions to kError post inCreatingCollection or inStrictConsistencyOrError is still pending

      Code Flow: the two pre constraints join the existing rule chains (changeStreamsMonitorStartedIfVerifying in the validator for kApplying to kStrictConsistency, committedUnlessAbortReason in the validator shared by all transitions to kDone). The three post constraints are set in the post slot of the table entries that SERVER-139808 adds, so every other transition keeps the default post-check.

      Reactions are not repeated per constraint; they follow the failure policies of SERVER-139806 (pre-checks throw before the write, except when entering kError or kDone, where only a tripwire fires) and SERVER-139808 (post-checks only report). For changeStreamsMonitorStartedIfVerifying that means a throw before the write, after which the recipient moves to kError, which is legal from kApplying.

      The two pre constraints need only SERVER-139806 and the three post constraints need SERVER-139808.

            Assignee:
            Brett Nawrocki
            Reporter:
            Nandini Bhartiya
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: