Non-retryable internal transactions refer to internal transactions started internally to execute some write for a client with retryWrite: false session. Such transactions always have session id of the form (id, uid, txnUUID) where where id is the id of the client session and txnUUID is an internally generated UUID. Such session ids are exclusively used to run internal transactions so they can never be used to run retryable writes. As such, they are not migrated during chunk migration. Currently, this is how they are excluded from session migration:
- The SessionCatalogMigrationSource filters out all sessions with session id of the form (id, uid, txnUUID) when it looks up existing sessions to migrate.
- The LogTransactionOperationsForShardingHandler does not add the opTime for transactions with session of the form (id, uid, txnUUID) to the new opTime buffer.
However, there have been some recent changes that can cause the the opTime for a non-retryable write internal transaction to end up in the new opTime buffer:
SERVER-71219made secondaries also use LogTransactionOperationsForShardingHandler to track writes in prepared transactions.- PM-3093 made secondary oplog application commit each prepared transaction in multiple "split sub sessions" which are sessions that come from the InternalSessionPool instead of the session that the transaction is in.
BF-28542 contains an example of how issue this manifests.
As a quick fix, SERVER-76806 will make SessionCatalogMigrationSource::_fetchNextNewWriteOplog just discard non-retryable internal transaction oplog entries it sees. Ideally, we should find a way to avoid adding the opTimes for non-retryable internal transactions to the SessionMigrationCatalogSource _newWriteOpTimeList buffer to avoid the wasted work on looking up the oplog entry here.
- related to
-
SERVER-76806 Make SessionCatalogMigrationSource new opTime processing ignore oplog entries for non-retryable internal transactions
- Closed
-
SERVER-77187 Consider making SplitPrepareSessionManager use internal sessions with session id (id, uid, txnUUID) to apply oplog entries for non-retryable internal transactions
- Closed