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

FeedRange: Fix split handling for readfeed split #1547

Merged
merged 13 commits into from
Jun 11, 2020

Conversation

ealsur
Copy link
Member

@ealsur ealsur commented May 20, 2020

Description

ReadFeed operations go through the PartitionKeyRangeHandler to resolve and the continuation token gets wrapped into a CompositeContinuationToken: https://github.com/Azure/azure-cosmos-dotnet-v3/blob/master/Microsoft.Azure.Cosmos/src/Handler/PartitionKeyRangeHandler.cs#L132

This 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

  • Bug fix (non-breaking change which fixes an issue)

@ealsur ealsur added the bug Something isn't working label May 20, 2020
@ealsur ealsur self-assigned this May 20, 2020
Copy link
Member

@kirankumarkolli kirankumarkolli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check comments

@@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public override bool IsDone => this.CompositeContinuationTokens.Count == 0;
public override bool IsDone => this.CompositeContinuationTokens.Any();

Copy link
Member Author

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];
Copy link
Contributor

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?

Copy link
Member Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.CurrentToken = this.CompositeContinuationTokens.Count > 0 ? this.CompositeContinuationTokens.Peek() : null;
if(!this.CompositeContinuationTokens.TryPeek(out this.CurrentToken)){
this.CurrentToken = null;
}

Copy link
Member Author

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

@ealsur ealsur merged commit 74141c9 into master Jun 11, 2020
@ealsur ealsur deleted the users/maquaran/readfeedsplit branch June 11, 2020 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants