Skip to content

Commit

Permalink
Updated the failure handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake Willey committed Oct 22, 2019
1 parent 0ec79d7 commit 33748f7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ protected async Task<bool> MoveNextHelperAsync(ItemProducerTree itemProducerTree
this.FailureResponse = moveNextResponse.failureResponse;
}

return !moveNextResponse.successfullyMovedNext;
return moveNextResponse.successfullyMovedNext;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected override string ContinuationToken
// With this information we have captured the progress for all partitions in a single continuation token.
get
{
if (this.IsDone || this.FailureResponse != null)
if (this.IsDone)
{
return null;
}
Expand Down Expand Up @@ -209,7 +209,8 @@ public override async Task<IReadOnlyList<CosmosElement>> InternalDrainAsync(int
//// 2) <i, j> always come before <i, k> where j < k

List<CosmosElement> results = new List<CosmosElement>();
while (!this.IsDone && results.Count < maxElements)
bool isSuccessToMoveNext = true;
while (!this.IsDone && results.Count < maxElements && isSuccessToMoveNext)
{
// Only drain from the highest priority document producer
// We need to pop and push back the document producer tree, since the priority changes according to the sort order.
Expand All @@ -234,10 +235,7 @@ public override async Task<IReadOnlyList<CosmosElement>> InternalDrainAsync(int

this.previousRid = orderByQueryResult.Rid;

if (await this.MoveNextHelperAsync(currentItemProducerTree, cancellationToken))
{
break;
}
isSuccessToMoveNext = await this.MoveNextHelperAsync(currentItemProducerTree, cancellationToken);

this.PushCurrentItemProducerTree(currentItemProducerTree);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public override async Task<IReadOnlyList<CosmosElement>> InternalDrainAsync(int
for (int i = 0; i < Math.Min(itemsLeftInCurrentPage, maxElements); i++)
{
results.Add(currentItemProducerTree.Current);
if (await this.MoveNextHelperAsync(currentItemProducerTree, cancellationToken))
if (!await this.MoveNextHelperAsync(currentItemProducerTree, cancellationToken))
{
break;
}
Expand Down

0 comments on commit 33748f7

Please sign in to comment.