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

[6.0.1] Microsoft.Data.Sqlite: Clean up on application exit #26529

Merged
merged 2 commits into from
Nov 10, 2021

Conversation

bricelam
Copy link
Contributor

@bricelam bricelam commented Nov 3, 2021

Hooks AppDomain.ProcessExit to clean up native resources.

Fixes #26422

Customer Impact

Databases using the write-ahead journal mode (the default for ones created by EF Core) create additional temporary files next to the database file. These files are cleaned up when the native connection is closed.

Previously, Microsoft.Data.Sqlite relied on DbConnection.Close, IDisposable, and finalizers to close the native connection.

A connection pool was added in 6.0 which keeps the native connection open after the DbConnection is closed/disposed/finalized.

Even though we leverage SafeHandle to close native connections, these finalizers are not called when the application is exits. This results in the temporary files not being properly cleaned up.

Regression?

Yes, the connection pool was added in 6.0. The temporary files were always cleaned up if the DbConnection was disposed.

Risk

Low. This is the same mechanism used by other ADO.NET providers.

Verification

Manually verified that the temporary journal files are now cleaned up on application exit.

@bricelam bricelam requested a review from a team November 3, 2021 17:17
@ajcvickers ajcvickers added this to the 6.0.x milestone Nov 4, 2021
@leecow leecow modified the milestones: 6.0.x, 6.0.1 Nov 4, 2021
@danmoseley
Copy link
Member

Please consider quirk for safety.

@wtgodbe wtgodbe merged commit 6ae128a into dotnet:release/6.0 Nov 10, 2021
@ajcvickers ajcvickers removed this from the 6.0.1 milestone Nov 17, 2021
@bricelam bricelam deleted the not-a-destructor branch April 19, 2022 20:14
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.

6 participants