-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Sqlite tests with transactions are flaky #16234
Comments
I believe the first failure shown is the real issue--seems to be a race condition in disposing a transaction that was not committed. The second two issues happen because the transaction on the shared connection failed in the first test. |
Which version of SQLitePCLRaw is involved here? The 2.0 prerelease? Or 1.x? |
@ericsink - 1.1.12 |
@ajcvickers @smitpatel Have you seen this recently? (How much time should I spend investigating?) |
@bricelam Yes--I see it a few times per week when running locally. From a test flakiness perspective it doesn't need doing for 3.0, but it looks like a product bug. It's worth spending a couple of hours on I think. |
I'm only able to repro this when disposing the connection and transaction on different threads. Test issue? |
This is the test issue I most often see associated with this failure: #17017 |
I haven't seen any association between both of them. Especially, they are also for different providers. |
@smitpatel Sometimes it happens with the SQL Server tests; sometimes with the SQLite tests. The message is different, but the symptom is the same--attempting to use an ambient transaction across threads. I suspect it has something to do with the way tests share a connection, but I haven't validated that. |
Sorry, I interpreted as the other test issue had something to cause this rather than both have similar root cause. |
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. |
I am hitting following errors intermittently when running build.cmd on command line. Re-running gets rid of the error.
The text was updated successfully, but these errors were encountered: