-
Notifications
You must be signed in to change notification settings - Fork 494
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
[Internal] Query: Fixes ORDER BY issue when partial partition key is specified in RequestOptions in a query to sub-partitioned container #4587
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
adityasa
requested review from
khdang,
sboshra,
neildsh,
kirankumarkolli,
ealsur,
FabianMeiswinkel and
kirillg
as code owners
July 11, 2024 23:13
neildsh
reviewed
Jul 15, 2024
Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/HierarchicalPartitionUtil.cs
Outdated
Show resolved
Hide resolved
neildsh
previously approved these changes
Jul 15, 2024
Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/HierarchicalPartitionUtil.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/HierarchicalPartitionUtil.cs
Outdated
Show resolved
Hide resolved
...os/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByCrossPartitionQueryPipelineStage.cs
Outdated
Show resolved
Hide resolved
...os/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByCrossPartitionQueryPipelineStage.cs
Outdated
Show resolved
Hide resolved
...os/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByCrossPartitionQueryPipelineStage.cs
Outdated
Show resolved
Hide resolved
...os/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByCrossPartitionQueryPipelineStage.cs
Show resolved
Hide resolved
...os/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByCrossPartitionQueryPipelineStage.cs
Outdated
Show resolved
Hide resolved
.../Query/Core/Pipeline/CrossPartition/OrderBy/OrderByQueryPartitionRangePageAsyncEnumerator.cs
Outdated
Show resolved
Hide resolved
.../Query/Core/Pipeline/CrossPartition/OrderBy/OrderByQueryPartitionRangePageAsyncEnumerator.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Pagination/InMemoryContainer.cs
Show resolved
Hide resolved
Great description! So just to confirm the change is already covered by existing tests in SubPartitionTests ? |
Correct. I confirmed that the test fails with same same symptoms as reported by cx without the call to HierarchicalPartitionutils from OrderBy Inner Enumerator. |
adityasa
force-pushed
the
users/adityasa/OrderByWrongResults
branch
from
July 16, 2024 00:37
8feb272
to
ba93330
Compare
neildsh
approved these changes
Jul 16, 2024
kirankumarkolli
approved these changes
Jul 16, 2024
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
adityasa
added
auto-merge
Enables automation to merge PRs
and removed
auto-merge
Enables automation to merge PRs
labels
Jul 17, 2024
Pilchie
approved these changes
Jul 17, 2024
.../Query/Core/Pipeline/CrossPartition/OrderBy/OrderByQueryPartitionRangePageAsyncEnumerator.cs
Show resolved
Hide resolved
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Template
Description
This changes addresses the issue that when an ORDER BY query is issued to a sub-partitioned container with partial partition key in the request options, documents outside the specified logical partition can also be retrieved. This happens if the logical partition range specified by partition key is split across multiple physical partitions (as with all HPK related issues so far) and one of the physical partitions contains data from other logical partitions (which is very likely, especially if a split has taken place).
With the previous fix made in following PR, which is still a required fix, we ensured that in cases when logical partition is split across multiple physical partitions, we perform a cross-partition ordering in the client:
#4507
However, as a result of this change, information regarding the logical partition key is not honored and each physical partition gets queried fully. This is because enumerator is scoped to full partition and when request is issued, epk range header is not specified in the request (only partition id is specified)
This change refactors the existing logic (used in another pipeline) to limit the FeedRangeEpk used by the enumerator to the intersection of physical partition range and logical partition feed range. This effectively limits the query epk range (by including correct header) for cases when a physical partition contains data from other logical partitions as well.
As far as testing is concerned, the InMemoryContainer was already able to repro this case as part of previous change. And it was originally thought to be the issue with the test infra in the previous change and a fix was applied to suppress this issue. The change removes this suppression and it was confirmed that existing ORDER BY queries in SubPartitionedTests repro the issue.
Type of change
Please delete options that are not relevant.
To automatically close an issue: closes #4563