[SERVER-30051] use collation in the shardCollection request, not collection default collation, to set shard key's collation Created: 07/Jul/17  Updated: 27/Oct/23  Resolved: 10/Jul/17

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.5.9
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: Esha Maharishi (Inactive)
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-30071 _configsvrShardCollection should dedu... Closed
Operating System: ALL
Backport Requested:
v3.4
Sprint: Sharding 2017-07-31
Participants:

 Description   

The shardCollection command should pass the collation sent in the shardCollection request, not the collection's default collation retrieved from the shard as it currently does, to the shardCollection helper. The shardCollection helper uses the passed-in collation to set the collation for the shard key, which actually cannot have anything but the simple collation.

This seems like it has been a bug since its implementation?



 Comments   
Comment by Esha Maharishi (Inactive) [ 10/Jul/17 ]

Agreed - the uassert that compares the shardCollection request's options to the options the collection is already sharded with should happen after the collation to store has been determined.

Comment by David Storch [ 10/Jul/17 ]

esha.maharishi and I discussed this in person. It looks to me like the checks in shardCollection related to collation are correct. We are careful to fail if the collection being sharded has a non-simple default collation but the shardCollection command does not specify {locale: "simple"}:

https://github.com/mongodb/mongo/blob/68eb01501452996e2f7102cf0219c13c75a12e74/src/mongo/db/s/config/configsvr_shard_collection_command.cpp#L355-L364

Furthermore, it looks to me like the defaultCollation we are storing in the sharding catalog is correct. This is the default collation of the collection, which can be non-simple, not the shard key collation, which must be {locale: "simple"}.

Comment by Esha Maharishi (Inactive) [ 07/Jul/17 ]

After looking into this, I think this may need to be backported to 3.4, since it affects shard targeting.

tess.avitabile, david.storch, does that sound correct?

Generated at Thu Feb 08 04:22:31 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.