Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-33991

Pass txnNumber all the getMore command on mongos

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.7.6
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • Sharding 2018-04-23, Sharding 2018-05-07

      Old Description:

      txnNumber must be passed through getMore command to implement global snapshot reads.

      Proposed approach:

      1. Add boost::optional private field _txnNumber to:

      • AsyncResultsMerger
      • ClusterClientCursor(Impl / Mock)
      • ClusterCursorManager::PinnedCursor

      2. In the ClusterClientCursorImpl constructors

      • Take the txnNumber from the opCtx

      3. In AsyncResultsMerger constructor

      • Take the txnNumber from the opCtx
        • I'm pretty sure this is guaranteed to be the same opCtx and txnNumber as the one used in the ClusterClientCursorImpl constructors, but if it's not, I can also thread the txnNumber from the ClusterClientCursor down into the AsyncResultsMerger some other way. Using the opCtx seemed cleaner for a first attempt though.

      Note: I need to store it in two places because the ARM needs the txnNumber to attach it to getMore requests and the ClusterClientCursor needs it to surface it to the PinnedCursor checked out in ClusterFind::runGetMore so we can validate the txnNumber sent by the user in subsequent getMores

      4. In AsyncResultsMerger::_askForNextBatch

      • If the ARM has a txnNumber, attach it to the getMore request (by std::moving the getMore cmdObj into a BSONObjBuilder to avoid copying) here

      5. In ClusterFind::runGetMore

      • Assert the txnNumber on the opCtx equals the txnNumber on the checked out pinned cursor here
      • If they don't match, return the cursor to the CursorManager so it isn't deleted and can be used by subsequent requests (this seems to match the behavior on mongod)

      6. Delete getMore txnNumber check in ShardingTaskExecutor here

      Here's a POC I made that passes the existing global snapshot reads tests we have, if this approach is approved, I'll add more testing, esp. unit tests: https://mongodbcr.appspot.com/201070002

            Assignee:
            jack.mulrow@mongodb.com Jack Mulrow
            Reporter:
            misha.tyulenev@mongodb.com Misha Tyulenev
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: