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

Fixed a bug that caused sortedRanges exception #835

Merged
merged 3 commits into from
Sep 24, 2019

Conversation

j82w
Copy link
Contributor

@j82w j82w commented Sep 20, 2019

Pull Request Template

Description

There was a bug where the SDK could not handle collisions in the effective partition key. Normally this is pretty much impossible, since the epk is 128, but in HashV1 we only hash the first 100 bytes. This means any two strings with the same large prefix will collide. This collision caused an assertion error (the query ranges were not sorted and non-overlapping (because there was a perfect overlap)).

The client side solution was to push the invariant into the structure instead of the check. The client now puts all the ranges into a sorted set to avoid this issue. In future this work should be pushed to the backend.

Fix is ported from internal PR: https://msdata.visualstudio.com/DefaultCollection/CosmosDB/_git/CosmosDB/pullrequest/248585

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Closing issues

closes #833

Jake Willey added 2 commits September 20, 2019 07:02
…ctive partition key. Normally this is pretty much impossible, since the epk is 128, but in HashV1 we only hash the first 100 bytes. This means any two strings with the same large prefix will collide. This collision caused an assertion error (the query ranges were not sorted and non-overlapping (because there was a perfect overlap)).

The client side solution was to push the invariant into the structure instead of the check. The client now puts all the ranges into a sorted set to avoid this issue. In future this work should be pushed to the backend.

Internal PR: https://msdata.visualstudio.com/_git/CosmosDB/pullrequest/248585?path=%2FProduct%2FTests%2FManagement%2FCrossPartitionQueryTests.cs&_a=overview
@j82w j82w added bug Something isn't working QUERY labels Sep 20, 2019
@j82w j82w self-assigned this Sep 20, 2019
@j82w j82w changed the title Users/jawilley/query partition range fix Fixed a query bug that caused sortedRanges exception Sep 20, 2019
@j82w
Copy link
Contributor Author

j82w commented Sep 20, 2019

@kweebtronic here is the fix

@j82w j82w requested a review from bchong95 September 20, 2019 16:45
@j82w j82w changed the title Fixed a query bug that caused sortedRanges exception Fixed a bug that caused sortedRanges exception Sep 20, 2019
@kirankumarkolli kirankumarkolli merged commit 0ebb8bd into master Sep 24, 2019
@kirankumarkolli kirankumarkolli deleted the users/jawilley/query_partition_range_fix branch September 24, 2019 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QUERY
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"sortedRanges" exception when querying Unique Key IN list
3 participants