[SERVER-81330] Better error message when attempting to create a descending shard key Created: 22/Sep/23  Updated: 02/Nov/23  Resolved: 02/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.2.0-rc0

Type: Improvement Priority: Major - P3
Reporter: Joanna Cheng Assignee: Janna Golden
Resolution: Fixed Votes: 0
Labels: sharding-nyc-subteam3
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Sharding NYC
Backwards Compatibility: Fully Compatible
Sprint: Sharding NYC 2023-10-30, Cluster Scalability 2023-11-13
Participants:

 Description   

Shard key fields must be ascending, with at most one hashed field. Descending fields are not allowed (SERVER-8129)

When you attempt to create one with a descending field, the error message is confusing

[direct: mongos] test> sh.shardCollection("test.foo", {a:-1})
MongoServerError: Shard key { a: -1 } can contain at most one 'hashed' field, and/or multiple numerical fields set to a value of 1. Failed to parse field a

Can we reword this to be something like

Shard key XXXX can contain at most one 'hashed' field, and/or multiple fields with a value of 1 (ascending). Failed to parse field a

Or modify the code to have different error blocks for "more than one hashed field" and "invalid field value" to make the error message more tailored.



 Comments   
Comment by Githook User [ 01/Nov/23 ]

Author:

{'name': 'jannaerin', 'email': 'golden.janna@gmail.com', 'username': 'jannaerin'}

Message: SERVER-81330 Make error message more clear on an attempt to create descending shard key
Branch: master
https://github.com/mongodb/mongo/commit/6958d7e21b0edca6d7347882424a047ad397f171

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