Skip to content

.Net: MEVD: Add consistent error handling #11845

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

Conversation

westey-m
Copy link
Contributor

@westey-m westey-m commented May 1, 2025

Motivation and Context

#11512
#11552

Description

Contribution Checklist

Remove unecessary parameter naming.

Update Weaviate, sqlite and sql server

Update Qdrant and Redis

Add updates for CosmosNoSQL, Pinecone and Postrgres
@westey-m westey-m requested a review from a team as a code owner May 1, 2025 17:36
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel memory labels May 1, 2025
@github-actions github-actions bot changed the title MEVD: Add consistent error handling .Net: MEVD: Add consistent error handling May 1, 2025
@westey-m westey-m marked this pull request as draft May 1, 2025 17:47
@westey-m westey-m marked this pull request as ready for review May 1, 2025 19:07
Copy link
Member

@roji roji left a comment

Choose a reason for hiding this comment

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

LGTM as is.

@@ -546,17 +518,24 @@ private async Task CreateIndexesAsync(string collectionName, CancellationToken c
{ "indexes", indexArray }
};

await this._mongoDatabase.RunCommandAsync<BsonDocument>(createIndexCommand, cancellationToken: cancellationToken).ConfigureAwait(false);
var cursor = await this.RunOperationAsync(OperationName, () =>
this._mongoDatabase.RunCommandAsync<BsonDocument>(createIndexCommand, cancellationToken: cancellationToken)).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

One small unrelated note: the pattern of using RunOperationAsync which accepts a lambda creates additional allocations as the local variables within the lambda are closed over. In addition, the added async method adds additional overhead (state machine etc.); it's of course good practice to refactor common code out to a single function, but with async methods we need to be careful as that has a cost (much higher than non-async methods).

Both these are high-perf concerns which I definitely don't think we should care about at this point - but something to keep in mind for the future... My preference here would be to just do try/catch here: it eliminates the various overheads, and although it's a bit longer I think it actually makes the code slightly clearer (the exception handling is just laid out etc.).

(inlining try/catch/throw can have its own costs as the containing method can frequently no longer be inlined, but that's very unlikely to be a concern here).

Just voicing some thoughts.

@roji
Copy link
Member

roji commented May 2, 2025

One additional thought... IIUC the approach in this PR is to always catch a specific exception when wrapping with VectorStoreException - this is in order to avoid e.g. wrapping OperationCanceledException (#11512). That makes a lot of sense.

Just pointing out that we may have more than one exception bubbling up from below which we may want to wrap - this would be the case where the underlying SDK doesn't itself wrap everything in its own single exception but rather allows multiple exceptions to bubble up. For those cases, the current approach of a single generic type parameter for the exception type to catch (as in this PR) would be insufficient, and we may want to simply inline the try/catch (as suggested for perf reasons in #11845 (comment)).

But not critical for now - we can always fix/improve later as needed.

@westey-m westey-m merged commit fb341a7 into microsoft:feature-vector-data-preb3 May 2, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel memory .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants