-
Notifications
You must be signed in to change notification settings - Fork 803
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
Replace Cosmos Db metadata query with container query #2215
base: master
Are you sure you want to change the base?
Conversation
Run a container query rather than a metadata query if containers are specified
@dotnet-policy-service agree company="CFC Underwriting" |
{ | ||
var container = _cosmosClient.GetContainer(_options.DatabaseId, containerId); | ||
var query = new QueryDefinition($"SELECT 1 FROM {containerId}"); | ||
using var queryStream = container.GetItemQueryStreamIterator(query); |
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.
Don't you need to call .ReadNextAsync() to execute the operation against the container?
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.
@idkburkes is correct: This is correct. The query is not executed until you call await ReadNextAsync()
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.
The best I can do right now is ask the owners of the CosmosDB SDK to review the change.
{ | ||
foreach (var containerId in _options.ContainerIds) | ||
{ | ||
var container = _cosmosClient.GetContainer(_options.DatabaseId, containerId); |
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.
@leminh98 @Maya-Painter @sboshra @adityasa could someone from the CosmosDB Team please review this change?
Context: this code is executed quite frequently, from an ASP.NET health check which has almost 6m downloads on nuget.org: https://www.nuget.org/packages/AspNetCore.HealthChecks.CosmosDb
BTW we are soon going to implement #2325 and hopefully reduce the number of users of Microsoft.Azure.DocumentDB.Core package
What this PR does / why we need it:
Run a container query rather than a metadata query if containers are specified
Which issue(s) this PR fixes:
Execution of Cosmos Db account metadata queries that can result in throttling errors
Please reference the issue this PR will close: #[462]
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
Implementation change of existing functionality
Please make sure you've completed the relevant tasks for this PR, out of the following list: