[SERVER-69429] Missing checks in collMod for shard key and unique index Created: 02/Sep/22  Updated: 29/Oct/23  Resolved: 13/Oct/22

Status: Closed
Project: Core Server
Component/s: Catalog, Sharding
Affects Version/s: None
Fix Version/s: 6.1.1, 6.0.3, 6.2.0-rc0

Type: Bug Priority: Major - P3
Reporter: Frederic Vitzikam Assignee: Yuhong Zhang
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
causes SERVER-74841 collMod should not call catalogClient... Closed
Related
related to SERVER-69874 Document or possibly mitigate scenari... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v6.1, v6.0
Sprint: Execution Team 2022-10-17
Participants:

 Description   

 

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).



 Comments   
Comment by Githook User [ 21/Oct/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-69429 Check shard key compatibility during collMod convert to unique

(cherry picked from commit 12165e687bc06fbf5df03bfef5d570e9dae7b0e9)
Branch: v6.0
https://github.com/mongodb/mongo/commit/806ff5306840425bbe6cf8d06bc343d1294a3fb7

Comment by Githook User [ 21/Oct/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-69429 Check shard key restriction for indexes with `prepareUnique` option

(cherry picked from commit bef1987c88f68d932da97291dd95868b9dd54d2c)
Branch: v6.0
https://github.com/mongodb/mongo/commit/220b590ded50f6a07e7df010fd5f412fa57dfceb

Comment by Githook User [ 19/Oct/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-69429 Check shard key compatibility during collMod convert to unique

(cherry picked from commit 12165e687bc06fbf5df03bfef5d570e9dae7b0e9)
Branch: v6.1
https://github.com/mongodb/mongo/commit/c97c058c5d005b6baaa6c37809cd28e516d5d3c7

Comment by Githook User [ 19/Oct/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-69429 Check shard key restriction for indexes with `prepareUnique` option

(cherry picked from commit bef1987c88f68d932da97291dd95868b9dd54d2c)
Branch: v6.1
https://github.com/mongodb/mongo/commit/66c55634f2ee6ecdadef69aa840a64c954190c67

Comment by Githook User [ 13/Oct/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-69429 Check shard key compatibility during collMod convert to unique
Branch: master
https://github.com/mongodb/mongo/commit/12165e687bc06fbf5df03bfef5d570e9dae7b0e9

Comment by Githook User [ 13/Oct/22 ]

Author:

{'name': 'Yuhong Zhang', 'email': 'yuhong.zhang@mongodb.com', 'username': 'YuhongZhang98'}

Message: SERVER-69429 Check shard key restriction for indexes with `prepareUnique` option
Branch: master
https://github.com/mongodb/mongo/commit/bef1987c88f68d932da97291dd95868b9dd54d2c

Generated at Thu Feb 08 06:13:26 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.