From eb431f09fdede191bfe6bc6c2da9c8cb12d804a1 Mon Sep 17 00:00:00 2001 From: ta264 Date: Sun, 16 Jan 2022 22:00:47 +0000 Subject: [PATCH] Fixed: Close all database connections on shutdown to remove shm/wal files [common] --- src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs | 8 ++++---- src/NzbDrone.Host/AppLifetime.cs | 3 +++ src/NzbDrone.Host/Bootstrap.cs | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs b/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs index 1e62b6580..ccca19073 100644 --- a/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs +++ b/src/NzbDrone.Core/Instrumentation/DatabaseTarget.cs @@ -16,12 +16,11 @@ public class DatabaseTarget : TargetWithLayout, IHandle trayCallback = null Logger.Info(ex.Message); LogManager.Configuration = null; } + + // Make sure there are no lingering database connections + GC.Collect(); + GC.WaitForPendingFinalizers(); + SQLiteConnection.ClearAllPools(); } public static IHostBuilder CreateConsoleHostBuilder(string[] args, StartupContext context)