[SERVER-38971] Single shard query hits multiple shard if it includes end of chunk range Created: 13/Jan/19  Updated: 15/Nov/21  Resolved: 14/Jan/19

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

Type: Bug Priority: Major - P3
Reporter: James Hartig Assignee: Danny Hatcher (Inactive)
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File mongos.key.log    
Issue Links:
Duplicate
duplicates SERVER-20768 Mongos find query including upper bou... Backlog
Operating System: ALL
Steps To Reproduce:
  1. Query db.sessions4.find({r: "gce-us-east1", u: {$lt: "UxOVavlFZXtKRL5MnB+1uQ=="}}).limit(2).explain()
  2. It will show that it needs to query both shards

But if you instead remove one character from the u field:

db.sessions4.find({r: "gce-us-east1", u: {$lt: "UxOVavlFZXtKRL5MnB+1uQ="}}).limit(2).explain()

It will show that it only needs to query 1 shard

Participants:

 Description   

I have a sharded collection on r,u and the following chunks:

{ "r" : "gce-us-east1", "u" : "UwAbyt9D6Zo1qlfk0XptAQ==" } -->> \{ "r" : "gce-us-east1", "u" : "Uwa+Dw0ZrJLFb7mVj/GykQ==" } on : sessions_gce_us_east1_2 Timestamp(2075, 0)
{ "r" : "gce-us-east1", "u" : "Uwa+Dw0ZrJLFb7mVj/GykQ==" } -->> \{ "r" : "gce-us-east1", "u" : "UxOVavlFZXtKRL5MnB+1uQ==" } on : sessions_gce_us_east1_2 Timestamp(2076, 0)
{ "r" : "gce-us-east1", "u" : "UxOVavlFZXtKRL5MnB+1uQ==" } -->> \{ "r" : "gce-us-east1", "u" : "UypBVrgDwfPLcNfvhz8okw==" } on : sessions_gce_us_east1 Timestamp(1, 13711)
{ "r" : "gce-us-east1", "u" : "UypBVrgDwfPLcNfvhz8okw==" } -->> \{ "r" : "gce-us-east1", "u" : "V+DYS8SwGMnenYmNyvNQsA==" } on : sessions_gce_us_east1 Timestamp(1, 13712)

 

If I do a query that involves {u: "UxOVavlFZXtKRL5MnB+1uQ=="} then it will hit both shards even though it only needs to hit sessions_gce_us_east1_2.



 Comments   
Comment by Danny Hatcher (Inactive) [ 14/Jan/19 ]

Hello James,

Thank you for your report. You have encountered SERVER-20768. Any work that would resolve this scenario will be performed on that ticket so I will close this ticket as a duplicate.

Thank you,

Danny

Comment by James Hartig [ 13/Jan/19 ]

I attached verbose logging from mongos when I run the query. The relevant connection is "conn118"

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