[SERVER-74124] Disallow sharding with wildcard shard key pattern Created: 16/Feb/23 Updated: 29/Oct/23 Resolved: 23/Feb/23 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 4.2.0, 4.4.0, 5.0.0, 6.0.0, 6.3.0-rc0 |
| Fix Version/s: | 7.0.0-rc0, 6.0.5, 6.3.0-rc1, 4.4.20, 5.0.16 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Cheahuychou Mao | Assignee: | Cheahuychou Mao |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||
| Backport Requested: |
v6.3, v6.0, v5.0, v4.4, v4.2
|
||||||||||||||||||||||||
| Sprint: | Sharding NYC 2023-03-06 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Description |
|
Currently, the validation within the ShardKeyPattern class doesn't check that the shard key fields don't have the "$" prefix. So the shardCollection command depends on the index key pattern validation here to prevent a shard key like {"$x": 1} from being used. However, "$**" is a special field name is allowed to bypass this check. As a result, one can run a shardCollection command with the shard key with {"$**": 1} without getting any error. However, the resulting collection appears to have a number of unexpected behaviors. For example:
|
| Comments |
| Comment by Githook User [ 06/Mar/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: |
| Comment by Githook User [ 28/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit fbb8024e67150305f9fc94b3a5fe57f6b8403de3) |
| Comment by Githook User [ 28/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit 7137269) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit fbb8024e67150305f9fc94b3a5fe57f6b8403de3) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit 71372698d18785a374aa09bdd646d3c5dc2f227a) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit fbb8024e67150305f9fc94b3a5fe57f6b8403de3) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit 71372698d18785a374aa09bdd646d3c5dc2f227a) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit fbb8024e67150305f9fc94b3a5fe57f6b8403de3) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: (cherry picked from commit 71372698d18785a374aa09bdd646d3c5dc2f227a) |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: |
| Comment by Githook User [ 23/Feb/23 ] |
|
Author: {'name': 'Cheahuychou Mao', 'email': 'mao.cheahuychou@gmail.com', 'username': 'cheahuychou'}Message: |