[SERVER-12141] Cannot create appropriate tag ranges with compound shard key Created: 17/Dec/13 Updated: 08/Jan/16 Resolved: 18/Dec/13 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Sharding |
| Affects Version/s: | 2.4.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Chris Coppick | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Ubuntu |
||
| Issue Links: |
|
||||||||
| Operating System: | ALL | ||||||||
| Participants: | |||||||||
| Description |
|
We're using 2.4.3. We have a compound shard key, composed of a 'token' that's represented by an 8-digit int and an _id type field that's a hashed value. To be clear, we are NOT using shard-key hashing. An example shard key might look like:
With no tag ranges in place the data seems to distribute pretty well. But we want to use tag aware sharding. Assuming we have shards tagged 'A' and 'B', if we define tag ranges that look like:
All the data ends up on just one shard. If we define tag ranges that look like:
MongoDB complains (in the log) that the tag ranges are not valid. If we use MinKey everywhere instead of MaxKey:
The complaints go away but all the data still ends up on one shard. The token field is constructed in such a way that we can pretty much guarantee that there will never be a token < 11000000 or a token greater than a certain number. We put in rules to handle those cases anyway. We have plenty of data and there are lots of chunks being created. The chunks seem to be getting split very nicely within the ranges. Ideally, the first example would work since for the purposes of shard tagging we do not care about the _id value. But it does not. Either we just can't figure out how to define the tag ranges appropriately, or MongoDB just doesn't respect tag ranges in conjunction with a compound shard key. Any help would be appreciated. |
| Comments |
| Comment by Chris Coppick [ 17/Dec/13 ] |
|
So strings are not integers? Is that because of new math? Stupid new math. Hurray for fresh eyes. We've removed the quotes from the range rules and On Tue, Dec 17, 2013 at 11:04 AM, Scott Hernandez (JIRA) |
| Comment by Scott Hernandez (Inactive) [ 17/Dec/13 ] |
|
It looks like your shard key values for token are numbers not strings, like you are using in the tag ranges. So that could the simple problem right there because you are mixing types and your shard key values are not split as you expect. If not, can you please attach a dump of your config database and the log files from mongos where you see the errors. |