|
The TransactionRouter tracks the statement number of the first command it received and increments its notion of the current statement whenever the transaction is continued. There are behaviors conditional on if the current statement is the first overall, like retrying on certain stale config errors.
If the transaction API is used on a mongos within a client transaction, the API's first recursive command will continue the TransactionRouter transaction started by the client so despite that command likely being the first that could target a participant, the router will have opted out of all first overall statement behaviors.
Since the API will be a common use case going forward, we should enable those behaviors by having the TransactionRouter track the first statement number to actually target a participant, instead of the first overall. This can be accomplished by checking if the participant list is non-empty before incrementing the latestStmtId.
|