Skip to content

Commit

Permalink
Fixed bug where query client would use old diagnostics which would ca…
Browse files Browse the repository at this point in the history
…use an exception.
  • Loading branch information
Jake Willey committed Mar 19, 2020
1 parent 509a986 commit f0c2d9e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal abstract Task<QueryResponseCore> ExecuteItemQueryAsync(
Documents.ResourceType resourceType,
Documents.OperationType operationType,
QueryRequestOptions requestOptions,
CosmosDiagnosticsContext diagnosticsContext,
Action<QueryPageDiagnostics> queryPageDiagnostics,
SqlQuerySpec sqlQuerySpec,
string continuationToken,
Documents.PartitionKeyRangeIdentity partitionKeyRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ internal override async Task<QueryResponseCore> ExecuteItemQueryAsync(
ResourceType resourceType,
OperationType operationType,
QueryRequestOptions requestOptions,
CosmosDiagnosticsContext diagnosticsContext,
Action<QueryPageDiagnostics> queryPageDiagnostics,
SqlQuerySpec sqlQuerySpec,
string continuationToken,
PartitionKeyRangeIdentity partitionKeyRange,
Expand Down Expand Up @@ -155,7 +155,7 @@ internal override async Task<QueryResponseCore> ExecuteItemQueryAsync(
resourceType,
message,
partitionKeyRange,
diagnosticsContext);
queryPageDiagnostics);
}

internal override async Task<PartitionedQueryExecutionInfo> ExecuteQueryPlanRequestAsync(
Expand Down Expand Up @@ -265,7 +265,7 @@ private QueryResponseCore GetCosmosElementResponse(
ResourceType resourceType,
ResponseMessage cosmosResponseMessage,
PartitionKeyRangeIdentity partitionKeyRangeIdentity,
CosmosDiagnosticsContext diagnosticsContext)
Action<QueryPageDiagnostics> queryPageDiagnostics)
{
using (cosmosResponseMessage)
{
Expand All @@ -274,8 +274,8 @@ private QueryResponseCore GetCosmosElementResponse(
queryMetricText: cosmosResponseMessage.Headers.QueryMetricsText,
indexUtilizationText: cosmosResponseMessage.Headers[HttpConstants.HttpHeaders.IndexUtilization],
diagnosticsContext: cosmosResponseMessage.DiagnosticsContext);
queryPageDiagnostics(queryPage);

diagnosticsContext.AddDiagnosticsInternal(queryPage);
if (!cosmosResponseMessage.IsSuccessStatusCode)
{
return QueryResponseCore.CreateFailure(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ internal override Task<QueryResponseCore> ExecuteQueryAsync(
partitionKeyRange: partitionKeyRange,
isContinuationExpected: isContinuationExpected,
pageSize: pageSize,
diagnosticsContext: this.diagnosticsContext,
queryPageDiagnostics: this.AddQueryPageDiagnostic,
cancellationToken: cancellationToken);
}

Expand All @@ -105,5 +105,10 @@ internal override Task<PartitionedQueryExecutionInfo> ExecuteQueryPlanRequestAsy
this.diagnosticsContext,
cancellationToken);
}

private void AddQueryPageDiagnostic(QueryPageDiagnostics queryPageDiagnostics)
{
this.diagnosticsContext.AddDiagnosticsInternal(queryPageDiagnostics);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal override Task<QueryResponseCore> ExecuteItemQueryAsync(
ResourceType resourceType,
OperationType operationType,
QueryRequestOptions requestOptions,
CosmosDiagnosticsContext diagnosticsContext,
Action<QueryPageDiagnostics> queryPageDiagnostics,
SqlQuerySpec sqlQuerySpec,
string continuationToken,
PartitionKeyRangeIdentity partitionKeyRange,
Expand All @@ -82,7 +82,7 @@ internal override Task<QueryResponseCore> ExecuteItemQueryAsync(
resourceType: resourceType,
operationType: operationType,
requestOptions: requestOptions,
diagnosticsContext: diagnosticsContext,
queryPageDiagnostics: queryPageDiagnostics,
sqlQuerySpec: sqlQuerySpec,
continuationToken: continuationToken,
partitionKeyRange: partitionKeyRange,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public static List<ToDoItem> MockSinglePartitionKeyRangeContext(
ResourceType.Document,
OperationType.Query,
It.IsAny<QueryRequestOptions>(),
It.IsAny<CosmosDiagnosticsContext>(),
It.IsAny<Action<QueryPageDiagnostics>>(),
It.Is<SqlQuerySpec>(specInput => IsSqlQuerySpecEqual(sqlQuerySpec, specInput)),
previousContinuationToken,
It.Is<PartitionKeyRangeIdentity>(rangeId => string.Equals(rangeId.PartitionKeyRangeId, partitionKeyRange.Id) && string.Equals(rangeId.CollectionRid, collectionRid)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private static IList<ToDoItem> GenerateAndMockResponseHelper(
ResourceType.Document,
OperationType.Query,
It.IsAny<QueryRequestOptions>(),
It.IsAny<CosmosDiagnosticsContext>(),
It.IsAny<Action<QueryPageDiagnostics>>(),
It.Is<SqlQuerySpec>(specInput => MockItemProducerFactory.IsSqlQuerySpecEqual(sqlQuerySpec, specInput)),
previousContinuationToken,
It.Is<PartitionKeyRangeIdentity>(rangeId => string.Equals(rangeId.PartitionKeyRangeId, partitionKeyRange.Id) && string.Equals(rangeId.CollectionRid, containerRid)),
Expand Down Expand Up @@ -179,7 +179,7 @@ private static IList<ToDoItem> GenerateAndMockResponseHelper(
ResourceType.Document,
OperationType.Query,
It.IsAny<QueryRequestOptions>(),
It.IsAny<CosmosDiagnosticsContext>(),
It.IsAny<Action<QueryPageDiagnostics>>(),
It.Is<SqlQuerySpec>(specInput => MockItemProducerFactory.IsSqlQuerySpecEqual(sqlQuerySpec, specInput)),
previousContinuationToken,
It.Is<PartitionKeyRangeIdentity>(rangeId => string.Equals(rangeId.PartitionKeyRangeId, partitionKeyRange.Id) && string.Equals(rangeId.CollectionRid, containerRid)),
Expand Down

0 comments on commit f0c2d9e

Please sign in to comment.