-
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
Change Feed: Fixes pull model request count for NotModified scenario #2405
Conversation
Microsoft.Azure.Cosmos/src/Pagination/CrossPartitionRangePageAsyncEnumerator.cs
Outdated
Show resolved
Hide resolved
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.
Older Async enumerator contract seems reasonable.
Current/Next model is ambiguous and leads to mis-interpretations.
Can the looping be hardened with the current enumerator contract?
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.
LGTM
Expectation
Assuming a FeedRange that spans multiple partitions/EPK ranges, for example, EPK Range 1, 2, and 3.
Change Feed pull model logic when receiving a NotModified should be:
If the FeedRange spans a single partition/EPK range, for example, EPK Range 1.
Change Feed pull model logic when receiving a NotModified should be:
Current behavior
The current behavior is doing one extra request, that on the case of FeedRanges that span a single partition/EPK range, causes a 2x increase in number of requests.
Using the previous example, if the FeedRange spans EPK Range 1, 2, and 3, Change Feed pull model is doing:
If the FeedRange spans a single partition/EPK range, for example, EPK Range 1:
Logical fix
To solve it, we are now adding a
TryPeekNext
to theCrossPartitionRangePageAsyncEnumerator
, which will peek on the internal queue and attempt to return the next state that would be read.And doing 2 optimizations:
The PR contains tests to cover the logic and also updates the Contract tests to match what internal teams are actually really doing, the Contract tests got modified on previous PRs and diverged from what they were meant to cover.
Review tips
The 2 major changes in
CrossPartitionChangeFeedAsyncEnumerator
were:From:
To:
And adding a check for a single range scenario:
Type of change