Currently, we write the oplog right before we send the final update that commits the migration to the config server:
However, if the server restarts right before the final update it sent, then it is possible for dropIndex to sneak in and drop the necessary index required by the shard collection. When the CreateCoordinator gets restored and tries to redo, it will find out that the collection doesn't have the required index for the shard key pattern and fail.
Some context for why oplog was written before the final update: it was done to achieve the property where the oplog will have ts < any writes that come after the collection became sharded.
- is related to
-
SERVER-61887 Add a no-op oplog entry for shardCollection command
- Closed
-
SERVER-6491 Prevent dropping shard key index when alternative index doesn't exist
- Closed