ShardServerProcessInterface::renameIfOptionsAndIndexesHaveNotChanged is totally bypassing the DDL coordinator infrastructure and is currently only used for the $out stage.
Such stage requires a collection parameter and works as follows:
- User issues an aggregation including an $out stage with output collection db.outColl
- During the aggregation, documents are written to a temporary collection db.tmp.coll
- At the end of the aggregation, the temporary collection is renamed to db.coll by calling renameIfOptionsAndIndexesHaveNotChanged.
As a result, if any DDL is invoked on db.coll concurrently with the rename happening at point (3), both local and sharding catalog can end up in an inconsistent state.