createIndexes on mongos is currently broadcast to all shards rather than only targeting shards which own data for the collection, since listIndexes expects the primary shard to have all the indexes for the collection (and the primary shard might not own any chunks for the collection at some particular time) (SERVER-16273).
However, this means the collection is implicitly created on shards which don't own chunks for the collection AND don't have an entry for the collection in their storage engine (e.g., any shard that has never owned chunks for the collection). The collection is implicitly created on these shards without the collection options, including the collection's UUID.
To prevent this,
1) mongods running as --shardsvr should fail createIndexes with NamespaceNotFound rather than implicitly create the collection with the wrong options
2) for createIndexes on a sharded collection, mongos should ignore NamespaceNotFound errors from shards
3) for createIndexes on an unsharded collection, mongos should check if the collection exists on the primary shard, and explicitly create it if not before sending createIndexes to the primary shard
- is duplicated by
-
SERVER-30213 createIndexes can implicitly create collections on shards without propagating the collection options
- Closed
-
SERVER-30937 Migration failed because of `already exists with different options`
- Closed
-
SERVER-20659 balancer ignores collection storage engine options on moveChunk
- Closed
- is related to
-
SERVER-30025 for sharded read with empty query, target only shards that own data for the collection instead of all shards
- Closed
- related to
-
SERVER-20659 balancer ignores collection storage engine options on moveChunk
- Closed