The ensurePrimaryShard helper function is currently used to create a database on a specific primary shard (if not existing) or changing a db's primary shard (if existing).
Inspecting a sample of tests invoking it, it turns out that this function is used in the following ways:
- 83% of current usages: calling enableSharding + ensurePrimaryShard to simply create the db on a primary shard. This is technically equivalent to calling enableSharding (creating an empty database on a random primary shard) + movePrimary (in this case, moving an empty database).
- This can be avoided by just calling enableSharding with the primaryShard argument.
- 10% of current usages: calling ensurePrimaryShard to create a db on a specific primary shard.
- Also this can be avoided by just calling enableSharding with the primaryShard argument.
- 7% of current usages: used to actually change the primary shard of a non-empty database.
- This can be avoided by directly calling movePrimary.
Purpose of this ticket is to get rid of ensurePrimaryShard for the following reasons:
- Bring to an end the unnecessary pattern of creating an empty database and then moving it.
- Mark all the points in the code that really need movePrimary.
This is a precondition to deprecate the movePrimary command once moveCollection will be available, so there will not be too many tests to adapt in the future.
- is depended on by
-
SERVER-81461 Change tests that uses movePrimary to move data to use moveCollection
- Closed