-
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
Query: Fixes a bug where max page size is not being honored after the first 2 pages #2776
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors|Removes) Description"
Internal should be used for PRs that have no customer impact. This flag is used to help generate the changelog to know which PRs should be included. Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.
46f473d
to
baabf7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors|Removes) Description"
Internal should be used for PRs that have no customer impact. This flag is used to help generate the changelog to know which PRs should be included. Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.
Description
Query results were not honouring MaxItemCount after 2 pages. This causing the query to be slow and cost a lot of RUs.
As part of this PR fixing the bug.
Analysis:
It was found that we are loosing configured MaxItemCount somewhere in the flow and getting set as Int32 Max i.e. 2,147,483,647 which was leading to above issue.
So in this OrderByQueryPartitionRangePageAsyncEnumerator, We have InnerEnumerator which stores QueryPaginationOptions and there we have private field and one public field to store the same information. In the constructor of this, we were setting only private field and getter was getting value from the public field. So changed the code to set the public variable and remove the private variable.
Why it was affecting only after 2 pages?
For first page it gets the results with correct maxitemcount value and then merge the other partitions (multiple partition to single one e.g (A, B) (B, C) => (A,C)) due to which 2nd page makes a call but throws Split Exception and which goes to this code,
azure-cosmos-dotnet-v3/Microsoft.Azure.Cosmos/src/Query/Core/Pipeline/CrossPartition/OrderBy/OrderByCrossPartitionQueryPipelineStage.cs
Line 348 in 75f57bc
Where we are re-initializing OrderByQueryPartitionRangePageAsyncEnumerator with public variable of uninitializedEnumerator.QueryPaginationOptions which was null all the time. So here we are losing this value.
Type of change
Closing issues
To automatically close an issue: closes #2756