-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Fully Compatible
-
Sharding 2019-01-14, Sharding 2019-01-28, Sharding 2019-02-11, Sharding 2019-02-25, Sharding 2019-05-06, Sharding 2019-05-20
When creating a unique index on a collection and not every shard has a chunk of the collection, the error "request doesn't allow collection to be created implicitly" will supersede the unique index error message.
Create index on a sharded collection with 1 chunk on shard A and no chunks on shard B:
mongos> db.bar.createIndex( { z: 1 }, { unique: true }); { "ok" : 0, "errmsg" : "request doesn't allow collection to be created implicitly", "code" : 227, "codeName" : "CannotImplicitlyCreateCollection", "ns" : "test.bar", "operationTime" : Timestamp(1543854707, 1), "$clusterTime" : { "clusterTime" : Timestamp(1543854707, 41), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
Create index on a sharded collection with 1 chunk on shard A and 1 chunk on shard B:
mongos> db.foo.createIndex( { z: 1}, { unique: true } ) { "raw" : { "shardA/Kays-MacBook-Pro-2.local:27018,Kays-MacBook-Pro-2.local:27019,Kays-MacBook-Pro-2.local:27020" : { "ok" : 0, "errmsg" : "cannot create unique index over { z: 1.0 } with shard key pattern { _id: 1.0 }", "code" : 67, "codeName" : "CannotCreateIndex" }, "shardB/Kays-MacBook-Pro-2.local:27021,Kays-MacBook-Pro-2.local:27022,Kays-MacBook-Pro-2.local:27023" : { "ok" : 0, "errmsg" : "cannot create unique index over { z: 1.0 } with shard key pattern { _id: 1.0 }", "code" : 67, "codeName" : "CannotCreateIndex" } }, "code" : 67, "codeName" : "CannotCreateIndex", "ok" : 0, "errmsg" : "{ shardA/Kays-MacBook-Pro-2.local:27018,Kays-MacBook-Pro-2.local:27019,Kays-MacBook-Pro-2.local:27020: \"cannot create unique index over { z: 1.0 } with shard key pattern { _id: 1.0 }\", shardB/Kays-MacBook-Pro-2.local:27021,Kays-MacBook-Pro-2.local:27022,Kays-MacBook-Pro-2.local:27023: \"cannot create unique index over { z: 1.0 } with shard key pattern { _id: 1.0 }\" }", "operationTime" : Timestamp(1543854778, 2), "$clusterTime" : { "clusterTime" : Timestamp(1543854778, 2), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } }
- is duplicated by
-
SERVER-38686 [createIndex response format] mongos createIndex should prioritize other errors over CannotImplicitlyCreateCollection
- Closed