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

CosmosQueryExecutionContextFactory Refactory #988

Merged
merged 37 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c5bbc0e
drafted out refactor
bchong95 Nov 12, 2019
9cc75f9
removed null check
bchong95 Nov 12, 2019
b14bc0f
resolved some iteration comments
bchong95 Nov 12, 2019
e2d3563
reproduced failure
bchong95 Nov 13, 2019
39b50af
got exceptionless to work for non order by queries
bchong95 Nov 13, 2019
72b1198
got exceptionless working for order by
bchong95 Nov 13, 2019
69e0df2
got parallel basic working
bchong95 Nov 14, 2019
f5b8ab5
got non failure case working again
bchong95 Nov 14, 2019
bdbf605
got continuation token story working
bchong95 Nov 14, 2019
c1c5b2a
fixed miscellaneous tests
bchong95 Nov 15, 2019
dac7d8d
got all the combinations working for exceptionless
bchong95 Nov 15, 2019
f9d1715
added test for empty pages
bchong95 Nov 15, 2019
78130a2
uncommented
bchong95 Nov 15, 2019
ae8523f
wip
bchong95 Nov 15, 2019
25eefc4
resolved iteration comments
bchong95 Nov 15, 2019
58d4540
Merge branch 'master' into users/brchon/ImmutableQueryFactory
bchong95 Nov 15, 2019
17aed1e
fixed changelog
bchong95 Nov 15, 2019
fe870db
build
bchong95 Nov 15, 2019
4cc5159
build
bchong95 Nov 15, 2019
8e4dcf2
resolved iteration comments
bchong95 Nov 16, 2019
f422555
update test
bchong95 Nov 16, 2019
1fa6ae1
automatically advancing page
bchong95 Nov 16, 2019
2ec83e2
fixed some split failures
bchong95 Nov 16, 2019
ede9232
merged
bchong95 Nov 16, 2019
f346aaa
merged
bchong95 Nov 16, 2019
f3fce62
fixed split bugs
bchong95 Nov 17, 2019
816d3de
fixed continuation token exception
bchong95 Nov 17, 2019
d3e9280
merged
bchong95 Nov 17, 2019
3aace4a
added a catch all query excetuion context
bchong95 Nov 17, 2019
e2ebfc9
ammend
bchong95 Nov 17, 2019
65130fd
removed is done check for try get continuation token
bchong95 Nov 17, 2019
3f293e1
updated baseline
bchong95 Nov 17, 2019
511b991
fixed test since code doesn't just throw exceptions anymore
bchong95 Nov 17, 2019
d3771ec
removed stack trace from exception
bchong95 Nov 18, 2019
d07126b
updated error message one more time?
bchong95 Nov 18, 2019
4c73633
updated baselines
bchong95 Nov 18, 2019
be49066
merged
bchong95 Nov 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update test
  • Loading branch information
bchong95 committed Nov 16, 2019
commit f4225554f7dc2b1513af0c5a102984ed6d2069ff
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ public override async Task<QueryResponseCore> ExecuteNextAsync(CancellationToken
(queryResponse.SubStatusCode == Documents.SubStatusCodes.NameCacheIsStale) &&
!this.alreadyRetried)
{
this.currentCosmosQueryExecutionContext.Dispose();
await this.cosmosQueryContext.QueryClient.ForceRefreshCollectionCacheAsync(
this.cosmosQueryContext.ResourceLink.OriginalString,
cancellationToken);
try
{
await this.cosmosQueryContext.QueryClient.ForceRefreshCollectionCacheAsync(
this.cosmosQueryContext.ResourceLink.OriginalString,
cancellationToken);
}
finally
{
this.alreadyRetried = true;
this.currentCosmosQueryExecutionContext.Dispose();
}

this.currentCosmosQueryExecutionContext = this.cosmosQueryExecutionContextFactory();
this.alreadyRetried = true;
return await this.ExecuteNextAsync(cancellationToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,46 @@ public async Task ValidateQueryNotFoundResponse()

await container.DeleteContainerAsync();

FeedIterator crossPartitionQueryIterator = container.GetItemQueryStreamIterator(
{
// Querying after delete should be a gone exception even after the retry.
FeedIterator crossPartitionQueryIterator = container.GetItemQueryStreamIterator(
"select * from t where true",
requestOptions: new QueryRequestOptions() { MaxConcurrency = 2 });

await this.VerifyQueryNotFoundResponse(crossPartitionQueryIterator);
await this.VerifyQueryNotFoundResponse(crossPartitionQueryIterator);
}

FeedIterator queryIterator = container.GetItemQueryStreamIterator(
{
// Creating another query after the refresh should just be a regular not found.
FeedIterator queryIterator = container.GetItemQueryStreamIterator(
"select * from t where true",
requestOptions: new QueryRequestOptions()
{
MaxConcurrency = 1,
PartitionKey = new Cosmos.PartitionKey("testpk"),
});

await this.VerifyQueryNotFoundResponse(queryIterator);
await this.VerifyQueryNotFoundResponse(queryIterator);
}

{
// Recreate the collection with the same name on a different client.
CosmosClient newClient = TestCommon.CreateCosmosClient();
Container container2 = await db.CreateContainerAsync("NotFoundTest" + Guid.NewGuid().ToString(), "/pk", 500);
await container2.CreateItemAsync(randomItem);

FeedIterator crossPartitionQueryIterator2 = container.GetItemQueryStreamIterator(
FeedIterator queryIterator = container.GetItemQueryStreamIterator(
"select * from t where true",
requestOptions: new QueryRequestOptions() { MaxConcurrency = 2 });
requestOptions: new QueryRequestOptions()
{
MaxConcurrency = 1,
PartitionKey = new Cosmos.PartitionKey("testpk"),
});

await this.VerifyQueryNotFoundResponse(crossPartitionQueryIterator2);
ResponseMessage response = await queryIterator.ReadNextAsync();
Assert.IsNotNull(response);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
}

await db.DeleteAsync();
}
Expand Down Expand Up @@ -145,7 +164,7 @@ private async Task ItemOperations(Container container, bool containerNotExist)
private async Task VerifyQueryNotFoundResponse(FeedIterator iterator)
{
// Verify that even if the user ignores the HasMoreResults it still returns the exception
for(int i = 0; i < 3; i++)
for(int i = 0; i < 3 ; i++)
{
ResponseMessage response = await iterator.ReadNextAsync();
Assert.IsNotNull(response);
Expand Down