Fix flaky Linux SQLite CI tests#575
Merged
Aaronontheweb merged 1 commit intoFeb 15, 2026
Merged
Conversation
Three interacting bugs caused the "Linux - SQLite" CI job to fail consistently: 1. SqlDataOptionsEndToEndSpecBase.DisposeAsync() called _fixture.DisposeAsync(), destroying the shared collection fixture's in-memory databases and poisoning all subsequent test classes. This only manifested on Linux because the DataOptions specs have [SkipWindows] (active in Release config). 2. SqliteEndToEndSpec used [CollectionDefinition] instead of [Collection], creating a duplicate collection definition instead of joining the existing one. 3. SqliteContainer.InitializeDbAsync() used a null-forgiving operator on _heldConnection, which would NRE if the fixture had been prematurely disposed. Made both container classes defensive with null-coalescing initialization.
131058a to
e3b5521
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #574
The "Linux - SQLite" CI job has been failing consistently across PRs (#571, #572) while all other jobs pass. Three interacting bugs were identified:
Bug 1 (Primary):
SqlDataOptionsEndToEndSpecBase.DisposeAsync()destroys the shared collection fixtureDisposeAsync()called_fixture.DisposeAsync(), which closes all held SQLite connections and sets_heldConnection = null. This destroys every in-memory database in the collection fixture, causing all subsequent test classes (~24 classes) to fail.Why Linux-only:
SqliteDataOptionsEndToEndSpecandMsSqliteDataOptionsEndToEndSpechave[SkipWindows](active in Release config). On Windows CI the destructive dispose never runs. On Linux it poisons the fixture.Fix: Removed
_fixture.DisposeAsync()call — xUnit manages collection fixture lifecycle.Bug 2:
SqliteEndToEndSpecuses[CollectionDefinition]instead of[Collection]It accidentally defines the collection instead of joining it, creating a duplicate
CollectionDefinitionwith the real one inSqlitePersistenceSpec.cs. Compare withMsSqliteEndToEndSpecwhich correctly uses[Collection].Fix: Changed to
[Collection(nameof(SqlitePersistenceSpec))].Bug 3: Container
InitializeDbAsync()not defensive against null state_heldConnection!.Add(conn)would NRE if the fixture had been prematurely disposed.Fix: Added
_heldConnection ??= new List<>()to bothSqliteContainerandMsSqliteContainer.Test plan
dotnet buildsucceeds with 0 errors