[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:
Backports
Depends
Problem/Incident
Related
related to SERVER-85502 Change the shard key prefix error des... Backlog
is related to SERVER-48471 Hashed indexes may be incorrectly mar... Closed
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:
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:

  • No index exists with the shard key pattern as a prefix at all
  • An otherwise valid index exists, but is multikey, partial, sparse, is being built, or has a collation


 Comments   
Comment by Githook User [ 20/Dec/23 ]

Author:

{'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}

Message: SERVER-50792 Implement detailed shard key index errors

GitOrigin-RevId: ba235f670c873f8c50d4d67e061d5421059c189f
Branch: v5.0
https://github.com/mongodb/mongo/commit/57a94363803a031c2064d63607c0e2ed411ad873

Comment by Githook User [ 18/Dec/23 ]

Author:

{'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}

Message: SERVER-50792 Implement detailed shard key index errors

GitOrigin-RevId: 2145acd3c9d791d2e51cc9148503890049931b1f
Branch: v6.0
https://github.com/mongodb/mongo/commit/17fb1330badc4e776a1976589294889fa6bc505b

Comment by Githook User [ 25/Sep/23 ]

Author:

{'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}

Message: SERVER-50792 Returns useful errors for shard key index
Branch: v4.4
https://github.com/mongodb/mongo/commit/208a1887b7083b9ff345443de9be5242136386c1

Comment by Githook User [ 11/Aug/22 ]

Author:

{'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}

Message: cherry-pick SERVER-50792 a98ea3b6e7a8f8ae0dac783cde4f2b964fea75f7
Branch: israelhsu/BACKPORT-7941
https://github.com/mongodb/mongo/commit/86e675b74f39c08570d90fcf2ce9e07083fb4612

Comment by Githook User [ 15/Jun/22 ]

Author:

{'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}

Message: SERVER-50792 Exclude refine_collection_shard_key_basic.js from multiversion testing.
Branch: master
https://github.com/mongodb/mongo/commit/86640306b979c18d0873517be45a82d2b4b5ea9a

Comment by Githook User [ 15/Jun/22 ]

Author:

{'name': 'Israel Hsu', 'email': 'israel.hsu@mongodb.com', 'username': 'israelhsu'}

Message: SERVER-50792 Exclude check_shard_index.js test from multiversion testing
Branch: master
https://github.com/mongodb/mongo/commit/b4e5a74c23d7ca24dee2f996a0cd630624255aa6

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: SERVER-50792 Implement detailed shard key index errors
Branch: master
https://github.com/mongodb/mongo/commit/a98ea3b6e7a8f8ae0dac783cde4f2b964fea75f7

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.

Generated at Thu Feb 08 05:23:35 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.