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

Don't call SqliteConnection.RemoveCommand() from command finalizer #17269

Merged
merged 1 commit into from
Aug 20, 2019
Merged

Conversation

bricelam
Copy link
Contributor

Wrote a test locally to generate lots of garbage. This fixed a NullRef. Still couldn't repro #16234

command.Dispose();
}
else
{
_commands.RemoveAt(i);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

NB: Only trimming the list on connection.Close/Dispose() now, not command.Dispose()

@bricelam bricelam merged commit 260fad1 into dotnet:release/3.0-preview9 Aug 20, 2019
@bricelam bricelam deleted the finalize branch August 20, 2019 15:21
@TharisSolutionsLtd
Copy link

Hello,

I am having this same issue, but I am only getting it from an IHostedService. The hosted service is using the DbContext after creating a scope from the service provider (all within "using" statements). As the hosted service is basically spamming the database, this is what seems to cause the issue. Without fail, it always errors when the method SqliteConnection.RemoveCommand is called in the stack trace, no matter the origin of the call (happens after SqliteCommand.Dispose). The error could happen from: DbContext.Database.EnsureCreated, DbContext.Set<>.Find or generally any query from the DbSet. The exception message is always "Object reference not set to an instance of the object", but there are no objects in my control that are null, it seems like an SQLite framework issue. I am using Microsoft.EntityFrameworkCore.Sqlite v3.1.0 in .NET Core 3.1.

Running other integration tests via the WebApplicationFactory and replacing the provider with SQLite runs fine and works as I expect - I am using SQLite for testing to take advantage of the relational constraints it provides unlike the EF core in memory solution.

@ajcvickers
Copy link
Member

@TharisSolutionsLtd Please file a new issue and include a small, runnable project that reproduces the behavior you are seeing so that we can investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants