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
- is duplicated by
-
SERVER-33702 Move sessionId and txnNumber addition from ShardingTaskExecutor::scheduleRemoteCommand
- Closed