
OPERATIONAL DEFECT DATABASE
...

...
When sharding a collection with a hashed shard key but including invalid options will output the following error: mongos> sh.shardCollection("test.foo", {_id:"hashed"}, {pieinthesky:1}) { "ok" : 0, "errmsg" : "Hashed shard keys cannot be declared unique. It's possible to ensure uniqueness on the hashed field by declaring an additional (non-hashed) unique index on the field.", "code" : 72, "codeName" : "InvalidOptions", "operationTime" : Timestamp(1541185291, 4), "$clusterTime" : { "clusterTime" : Timestamp(1541185291, 4), "signature" : { "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="), "keyId" : NumberLong(0) } } } The problem is my invalid option, not the hashed shard key.
daniel.hatcher commented on Mon, 5 Nov 2018 16:35:55 +0000: Duplicates SERVER-37908 as the root issue is that the unique parameter (despite being optional) is required if options are specified.
Launch a sharded cluster sh.enableSharding("test") sh.shardCollection("test.foo", {_id:"hashed"}, {pieinthesky:1}) Error appears that is not indicative of the true problem
MongoDB Integration
Learn more about where this data comes from
Bug Scrub Advisor
Streamline upgrades with automated vendor bug scrubs
BugZero Enterprise
Wish you caught this bug sooner? Get proactive today.