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

movePrimary builds indexes in foreground on destination shard

    • Sharding
    • Fully Compatible
    • ALL

      The movePrimary command is used to move primary database and unsharded collections from one shard to another. When movePrimary clones a collection from the donor to the recipient shard, it will create indexes using a MultiIndexBlock. It does not call MultiIndexBlock::allowBackgroundBuilding() before executing. Without this call all index builds will be performed in the foreground, regardless of whether {background: true} is set in a given index's specification.

      Performing foreground index builds on the recipient shard will block all database read/write activity for the duration of each index build. This can be a significant period of time depending on data size and hardware resources available.

      We should look to build indexes in the background during movePrimary. If not possible, we should at a minimum update the movePrimary documentation to reflect.

      This also impacts CloudManager shard removal via automation, in the case where the shard being removed is the primary database for unsharded collections.

      For movePrimary index build code see:
      https://github.com/mongodb/mongo/blob/r3.2.1/src/mongo/db/cloner.cpp#L358-L370

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            james.wahlin@mongodb.com James Wahlin
            Votes:
            2 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved: