[SERVER-50792] Return more useful errors when a shard key index can't be found for shardCollection/refineCollectionShardKey Created: 08/Sep/20 Updated: 22/Jan/24 Resolved: 15/Jun/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | None |
| Fix Version/s: | 6.1.0-rc0, 4.4.26, 6.0.13, 5.0.24 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Jack Mulrow | Assignee: | Israel Hsu |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||||||
| Backport Requested: |
v6.0, v5.0
|
||||||||||||||||||||||||
| Sprint: | Sharding 2021-10-18, Sharding 2021-11-01, Sharding 2021-11-15, Sharding 2021-11-29, Sharding 2021-12-13, Sharding 2021-12-27, Sharding 2022-01-10, Sharding 2022-01-24, Sharding 2022-02-07, Sharding 2022-02-21, Sharding 2022-03-07, Sharding NYC 2022-03-21, Sharding NYC 2022-04-04, Sharding NYC 2022-04-18, Sharding 2022-05-02, Sharding NYC 2022-05-16, Sharding NYC 2022-05-30, Sharding NYC 2022-06-13, Sharding 2022-06-27 | ||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||||||
| Linked BF Score: | 173 | ||||||||||||||||||||||||
| Description |
|
When a collection is sharded or its shard key is refined, a "useful" index must exist on the collection that supports the proposed shard key (as defined in this comment). Verifying this involves both inspecting the collection's listIndexes output and running the checkShardingIndex command on a shard. An index with the shard key pattern can be invalid for several reasons (e.g. it's multikey, partial, sparse, has a collation, or is in the process of being built) but the error messages returned for many of these cases is the same, which can make diagnosing failures difficult. (Message when listIndexes finds no candidate index and message when checkShardingIndex finds no valid index.) Instead, the command should return more information as to why there is no valid index. In particular, the error should at least differentiate these cases:
|
| Comments |
| Comment by Githook User [ 20/Dec/23 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: GitOrigin-RevId: ba235f670c873f8c50d4d67e061d5421059c189f |
| Comment by Githook User [ 18/Dec/23 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: GitOrigin-RevId: 2145acd3c9d791d2e51cc9148503890049931b1f |
| Comment by Githook User [ 25/Sep/23 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: |
| Comment by Githook User [ 11/Aug/22 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: cherry-pick |
| Comment by Githook User [ 15/Jun/22 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: |
| Comment by Githook User [ 15/Jun/22 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: |
| Comment by Israel Hsu [ 13/Jun/22 ] |
|
This is a change in error message text; there is no impact on data written to the database or network messages. |
| Comment by Githook User [ 13/Jun/22 ] |
|
Author: {'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}Message: |
| Comment by Eric Milkie [ 08/Sep/20 ] |
|
In addition to returning the information to the command, I think it would be helpful to log a message in the mongod system log. Such errors are rare and it's sometimes difficult to figure out which node the mongos is running the checkShardingIndex command on. |