-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 3.0.9, 3.2.1
-
Component/s: Index Maintenance
-
Sharding
-
Fully Compatible
-
ALL
-
(copied to CRM)
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