The following does not fail:
db.coll.createIndex({"a": 1}, {unique: false}) sh.shardCollection( "test.coll", { b: 1 }, false, { collation: { locale: "simple" } } ) db.runCommand({ collMod: "coll", index: { keyPattern: {"a": 1}, prepareUnique: true}}) db.runCommand({ collMod: "coll", index: { keyPattern: {"a": 1}, unique: true}})
Unlike trying to create the index on "a" with {unique: true} after the shardCollection which would give
cannot create unique index over {a: 1.0} with shard key pattern {b: 1.0}
I found this as part of the work on unlike topologies for cluster to cluster replication (Mongosync).
- causes
-
SERVER-74841 collMod should not call catalogClient::getCollection during secondary replication
- Closed
- related to
-
SERVER-69874 Document or possibly mitigate scenario where shards end up with different prepareUnique and unique index settings
- Closed