-
Notifications
You must be signed in to change notification settings - Fork 494
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
CosmosClient::Dispose throws SynchronizationLockException #3700
Comments
@kundadebdatta Can you take a look at this report? @ohads-MSFT It looks like you are disposing the client while there are requests in-progress, is that expected? |
If the app is shutting down, what is the impact of these exceptions? The biggest impact is that you are leaving requests in-flight, right? |
@ealsur sounds right, I'm guessing the Cosmos SDK doesn't have any ASP.NET shutdown hooks to drain all pending requests
Arguably an even bigger impact is the fact that an exception is thrown from |
Fixed in the Microsoft.Azure.Cosmos.Direct package and will be delivered with the next release Microsoft.Azure.Cosmos.Direct |
Describe the bug
CosmosClient::Dispose()
throwsSynchronizationLockException
To Reproduce
We don't know exactly how to reproduce, but it happens on ASP.NET app shutdown. We have an
IDisposable
Cosmos Client registered to the ASP.NET DI that when disposed by the ASP.NET host, disposes all the different clients it created in a loop:Note that
.Value
isLazy<T>
so I suspect it could be that some of the clients above are actually created (newCosmosClient()
) during that loop .Expected behavior
Dispose()
should not throw exceptions.Actual behavior
CosmosClient::Dispose()
sometime throws as explained above (see full screenshot below)Environment summary
SDK Version: Microsoft.Azure.Cosmos 3.32.0 (latest at the time of writing)
OS Version: linux (
mcr.microsoft.com/dotnet/aspnet:7.0.2-cbl-mariner2.0-distroless
)Additional context
The text was updated successfully, but these errors were encountered: