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

Speedup handling of already executed statements in chunk migration session cloning

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 8.1.0-rc0, 8.0.0-rc11
    • Affects Version/s: 5.0.0, 6.0.0, 7.0.0, 8.0.0-rc0
    • Component/s: None
    • None
    • Catalog and Routing
    • Fully Compatible
    • v8.0
    • CAR Team 2024-06-24
    • 200

      We identify an inefficiency on the code that perform session cloning during chunk migrations.

      In particular SessionCatalogMigrationDestination::_processSessionOplog is called by the recipeint shard of a chunk migration for every oplog entry it receives from the donor through the _getNextSessionMods command.
      Then TransactionParticipant::checkStatementExecuted is used to skip the oplog entry if the relative statement has been already executed.

      This function is particularly slow because it needs to return the oplog entry associated with the given Statement ID. In order to do so, it traverses the entire history of the transaction and in case of ApplyOps entry it will also extract all the operations using repl::ApplyOps::extractOperationsTo.

      Proposal

      The SessionCatalogMigrationDestination only needs to know if the Statement got executed but it doesn't need the oplog entry associated with it. Thus, we could simply use TransactionParticipant::checkStatementExecutedNoOplogEntryFetch instead of TransactionParticipant::checkStatementExecuted , and avoid the expensive Transaction history travesal.

            Assignee:
            tommaso.tocci@mongodb.com Tommaso Tocci
            Reporter:
            tommaso.tocci@mongodb.com Tommaso Tocci
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: