Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Fixes split proofing logic for queries with logical partition key #1988

Merged
merged 3 commits into from
Nov 11, 2020

Conversation

bchong95
Copy link
Contributor

@bchong95 bchong95 commented Nov 7, 2020

Query: Fixes split proofing logic for queries with logical partition key

Description

Suppose the partition spans epk range A to E
And the user send a query with partition key that hashes to C

When we query the results the continuation token will look something like:

{
              "token": "blah",
              "range": {
                             "min": "A",
                             "max": "E"
              }
}

Now suppose there is a split that creates two partitions A to B and B to E

Now C will map to the partition that goes from B to E

When we run the following code:

https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/PartitionMapper.cs#L68

We are going to hit an exception, since the code looks for a partition to resume from which in this case should be B to E, but we have the value A to E and we are checking to see if a partition matches the start of range (in this case A).

This leads to an exception.

This code path doesn’t happen in the case of non partition key queries, since the call to get target partition key ranges gives the full set of ranges and we always finish reading from the left most partition before moving on to the right most partition.

This fix detects if we are in a single partition scenario and resumes from that partition. The longer term solution is to wire FeedRangeState throughout the query stack (similar to what we have for ChangeFeed: #1978).

@sboshra sboshra merged commit 8fc0c8b into master Nov 11, 2020
@sboshra sboshra deleted the users/brchon/Query/PartitionKeySplitProofing branch November 11, 2020 21:56
@ghost
Copy link

ghost commented Dec 15, 2021

Closing due to in-activity, pease feel free to re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants