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

Multiple DbContexts Get Dispose Errors #11

Open
brantburnett opened this issue Jul 4, 2019 · 0 comments
Open

Multiple DbContexts Get Dispose Errors #11

brantburnett opened this issue Jul 4, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@brantburnett
Copy link
Collaborator

If multiple DbContexts are created which share a set of options, calling Dispose on the second context gets an exception. This is because they share the same ClientConfiguration object, which means they share the same ThresholdLoggingTracer, which gets disposed by the first DbContext. Relates to https://issues.couchbase.com/browse/NCBC-2019

Exception message: System.ObjectDisposedException
  The collection has been disposed.
  Object name: 'BlockingCollection'.
Stack trace:
   at System.Collections.Concurrent.BlockingCollection`1.CheckDisposed()
   at System.Collections.Concurrent.BlockingCollection`1.CompleteAdding()
   at Couchbase.Tracing.ThresholdLoggingTracer.Dispose()
   at Couchbase.Cluster.Dispose(Boolean disposing)
   at Couchbase.Cluster.Dispose()
   at Microsoft.EntityFrameworkCore.Couchbase.Storage.Internal.CouchbaseClientWrapper.Dispose()
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose()
   at Microsoft.EntityFrameworkCore.DbContext.Dispose()

Steps to reproduce

Run query tests in EfCore.Couchbase.FunctionalTests

Note: Getting to this error requires some additional code changes to successfully create buckets when query tests are run, etc. Commits are forthcoming to put these in place, but I wanted to track this bug before I forgot.

@brantburnett brantburnett added the bug Something isn't working label Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant