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

_getNextSessionMods shouldn't transfer oplog entries for transaction commits during cloning

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.1.10
    • Affects Version/s: None
    • Component/s: Sharding
    • Labels:
      None
    • Fully Compatible
    • ALL
    • Sharding 2019-03-11, Sharding 2019-03-25
    • 15

      During the cloning phase of a migration, in addition to transferring CRUD ops, the donor shard transfers the oplog entries associated with new retryable writes to the recipient shard, so the writes can still be retried if the migration succeeds. This is done by adding the opTimes of retryable write oplog entries to the donor shard cloner's SessionCatalogMigrationSource in WriteUnitOfWork commit handlers registered in insert/update/delete op observers and returning the entries associated with those times when the recipient shard calls _getNextSessionMods on the donor.

      When transactions are committed, a commit transaction op observer fires that runs the CRUD op observers for each write in the transaction. Currently these CRUD observers are run with the opTime of the commit oplog entry and will add this opTime to the migration cloner's SessionCatalogMigrationSource, if it exists, leading _getNextSessionMods to transfer the commit oplog entry to the recipient shard.

      This can lead to migration failures when the recipient checks out the TransactionParticipant associated with the commit, because the migrating thread assumes the txnId is for a retryable write and will throw InvalidOptions if the recipient was involved in the transaction and its TransactionParticipant isn't in the expected state for a retryable write (i.e. kNone).

      Only the oplog entries for retryable writes need to be transferred, so this can be fixed by never passing an opTime from a transaction statement to the SessionCatalogMigrationSource in MigrationChunkClonerSourceLegacy.

            Assignee:
            blake.oler@mongodb.com Blake Oler
            Reporter:
            jack.mulrow@mongodb.com Jack Mulrow
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: