-
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
FeedRange: Fix split handling for readfeed split #1547
Conversation
Microsoft.Azure.Cosmos/src/FeedRange/Continuations/FeedRangeCompositeContinuation.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/FeedRange/Continuations/FeedRangeCompositeContinuation.cs
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.
Please check comments
Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/FeedRange/Continuations/FeedRangeCompositeContinuation.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/FeedRange/Continuations/FeedRangeCompositeContinuation.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/FeedRange/Continuations/FeedRangeCompositeContinuation.cs
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs
Outdated
Show resolved
Hide resolved
Microsoft.Azure.Cosmos/src/Resource/FeedIterators/FeedRangeIteratorCore.cs
Outdated
Show resolved
Hide resolved
@@ -140,7 +130,7 @@ public override TryCatch ValidateContainer(string containerRid) | |||
/// <summary> | |||
/// The concept of Done is only for ReadFeed. Change Feed is never done, it is an infinite stream. | |||
/// </summary> | |||
public override bool IsDone => this.doneRanges.Count == this.CompositeContinuationTokens.Count; | |||
public override bool IsDone => this.CompositeContinuationTokens.Count == 0; |
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.
public override bool IsDone => this.CompositeContinuationTokens.Count == 0; | |
public override bool IsDone => this.CompositeContinuationTokens.Any(); |
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.
No, this would do the opposite. Done is if there are no more items in the queue, the change with Any
would return true if there is at least one.
|
||
if (compositeContinuationTokens != null && compositeContinuationTokens.Count > 0) | ||
{ | ||
compositeContinuationToken = compositeContinuationTokens[0]; |
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.
What happens to the other composite continuation tokens? Shouldn't this output a list of composite continuation tokens or should it be renamed to TryParseFirstCompositeContinuationToken?
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.
This is the same logic that exists in PartitionKeyRangeHandler, the list is a backward compatible measure, it contains 1 item
} | ||
|
||
this.CurrentToken = this.CompositeContinuationTokens.Count > 0 ? this.CompositeContinuationTokens.Peek() : null; |
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.
this.CurrentToken = this.CompositeContinuationTokens.Count > 0 ? this.CompositeContinuationTokens.Peek() : null; | |
if(!this.CompositeContinuationTokens.TryPeek(out this.CurrentToken)){ | |
this.CurrentToken = null; | |
} |
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.
I am tempted to pick this change, but I already know the current state passes all expected validations. I would need to validate splits on master all over with any code changes and this is mainly a readability optimization
Description
ReadFeed operations go through the
PartitionKeyRangeHandler
to resolve and the continuation token gets wrapped into aCompositeContinuationToken
: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs#L132This wrapping only affects Document ReadFeeds because Change Feed does not use CT (but rather ETag).
FeedRangeContinuation
handles splits by creating a list of CompositeContinuationTokens for the child partitions and copying the parent's continuation to them.For ReadFeed the problem is that if we just simply copy the token to the children, the Token has the original range that got processed by the PartitionKeyRangeHandler and when the next request happens and it sends the parent's CT, the PartitionKeyRangeHandler will try and honor the CT's Range instead of the FeedRange: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs#L94
This PR handles the wrapping of the PartitionKeyRangeHandler conditionally during a split-handling.
Type of change