Corrupt Database Error Keeps Reoccurring

Sonarr version (exact version): 3.0.9.1549
Mono version (if Sonarr is not running on Windows):
OS: Windows 11 22H2
Debug logs:
Description of issue: Keep having to reinstall Sonarr because I am getting a database error and it will not start. Reinstalling Sonarr on top of itself always solves the issue without having to restore the database. It will run for a week or two without issue, but this keeps happening. I’ve had to reinstall it 5 or 6 times now. The database is in the default location on the Windows system drive.

System.ApplicationException: Invalid XML in file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config' near element ''. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

at System.BaseConfigHandler.RunParser(String fileName)
at System.ConfigTreeParser.Parse(String fileName, String configPath, Boolean skipSecurityStuff)
— End of inner exception stack trace —
at System.ConfigTreeParser.Parse(String fileName, String configPath, Boolean skipSecurityStuff)
at System.Security.Cryptography.CryptoConfig.OpenCryptoConfig()
at System.Security.Cryptography.CryptoConfig.InitializeConfigInfo()
at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args)
at System.Security.Cryptography.RandomNumberGenerator.Create()
at System.MarvinHash.GenerateSeed()
at System.MarvinHash…cctor()
— End of inner exception stack trace —
at System.Xml.NameTable…ctor()
at System.Xml.XmlTextReaderImpl…ctor(XmlResolver resolver, XmlReaderSettings settings, XmlParserContext context)
at System.Xml.XmlTextReaderImpl…ctor(TextReader input, XmlReaderSettings settings, String baseUriStr, XmlParserContext context)
at System.Xml.XmlReaderSettings.CreateReader(TextReader input, String baseUriString, XmlParserContext inputContext)
at System.Xml.XmlReader.Create(TextReader input, XmlReaderSettings settings, String baseUri)
at System.Xml.Linq.XDocument.Parse(String text, LoadOptions options)
at NzbDrone.Core.Configuration.ConfigFileProvider.LoadConfigFile() in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Configuration\ConfigFileProvider.cs:line 356
at NzbDrone.Core.Configuration.ConfigFileProvider.<>c__DisplayClass55_0.b__0() in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Configuration\ConfigFileProvider.cs:line 254
at NzbDrone.Common.Cache.Cached1.Get(String key, Func1 function, Nullable1 lifeTime) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Common\Cache\Cached.cs:line 104 at NzbDrone.Core.Configuration.ConfigFileProvider.GetValue(String key, Object defaultValue, Boolean persist) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Configuration\ConfigFileProvider.cs:line 252 at NzbDrone.Core.Configuration.ConfigFileProvider.get_LogLevel() in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Configuration\ConfigFileProvider.cs:line 186 at NzbDrone.Core.Instrumentation.ReconfigureLogging.Reconfigure() in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Instrumentation\ReconfigureLogging.cs:line 27 at NzbDrone.Host.Bootstrap.Start(ApplicationModes applicationModes, StartupContext startupContext) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Host\Bootstrap.cs:line 66 at NzbDrone.Host.Bootstrap.Start(StartupContext startupContext, IUserAlert userAlert, Action1 startCallback) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Host\Bootstrap.cs:line 41
at NzbDrone.Console.ConsoleApp.Main(String[] args) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Console\ConsoleApp.cs:line 42

2023-02-15 09:23:10.9|Info|Bootstrap|Starting Sonarr - C:\ProgramData\Sonarr\bin\Sonarr.exe - Version 3.0.9.1549
2023-02-15 09:23:11.8|Info|Router|Application mode: Interactive
2023-02-15 09:23:12.1|Info|MigrationLogger|*** Checking database for required migrations data source=C:\ProgramData\Sonarr\sonarr.db;cache size=-10000;datetimekind=Utc;journal mode=Wal;pooling=True;version=3 ***
2023-02-15 09:23:13.7|Fatal|WindowsApp|EPIC FAIL

[v3.0.9.1549] NzbDrone.Core.Datastore.CorruptDatabaseException: Database file: C:\ProgramData\Sonarr\sonarr.db is corrupt, restore from backup if available. See: Sonarr FAQ | WikiArr —> System.Data.SQLite.SQLiteException: unable to open database file
at System.Data.SQLite.SQLite3.Open(String strFilename, String vfsName, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool)
at System.Data.SQLite.SQLiteConnection.Open()
at FluentMigrator.Runner.Processors.GenericProcessorBase.EnsureConnectionIsOpen()
at FluentMigrator.Runner.Processors.SQLite.SQLiteProcessor.Exists(String template, Object[] args)
at FluentMigrator.Runner.Processors.SQLite.SQLiteProcessor.TableExists(String schemaName, String tableName)
at FluentMigrator.Runner.VersionLoader.get_AlreadyCreatedVersionTable()
at FluentMigrator.Runner.VersionLoader.LoadVersionInfo()
at FluentMigrator.Runner.VersionLoader…ctor(IMigrationRunner runner, IAssemblyCollection assemblies, IMigrationConventions conventions)
at FluentMigrator.Runner.MigrationRunner…ctor(IAssemblyCollection assemblies, IRunnerContext runnerContext, IMigrationProcessor processor)
at NzbDrone.Core.Datastore.Migration.Framework.MigrationController.Migrate(String connectionString, MigrationContext migrationContext) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\Migration\Framework\MigrationController.cs:line 60
at NzbDrone.Core.Datastore.DbFactory.CreateMain(String connectionString, MigrationContext migrationContext) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\DbFactory.cs:line 117
— End of inner exception stack trace —
at NzbDrone.Core.Datastore.DbFactory.CreateMain(String connectionString, MigrationContext migrationContext) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\DbFactory.cs:line 128
at NzbDrone.Core.Datastore.DbFactory.Create(MigrationContext migrationContext) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\DbFactory.cs:line 82
at NzbDrone.Core.Datastore.DbFactory.Create(MigrationType migrationType) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\DbFactory.cs:line 70
at NzbDrone.Core.Datastore.DbFactory.RegisterDatabase(IContainer container) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Datastore\DbFactory.cs:line 48
at NzbDrone.Host.NzbDroneServiceFactory.Start() in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Host\ApplicationServer.cs:line 60
at NzbDrone.Host.Router.Route(ApplicationModes applicationModes) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Host\Router.cs:line 56
at NzbDrone.Host.Bootstrap.Start(ApplicationModes applicationModes, StartupContext startupContext) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Host\Bootstrap.cs:line 78
at NzbDrone.Host.Bootstrap.Start(StartupContext startupContext, IUserAlert userAlert, Action`1 startCallback) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Host\Bootstrap.cs:line 41
at NzbDrone.WindowsApp.Main(String[] args) in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone\WindowsApp.cs:line 23

This is a corrupt XML file for the framework. Is your hard drive failing?

Reinstalling Sonarr doesn’t touch the database, unless the database is removed/recreated. If you’re restoring a DB from backup it’s possible that it’s corrupt and the issue keeps reoccurring that way.

I’m not seeing anything to indicate an HD error in the event logs. The only issue that is occurring on this PC as far as I can tell is the Sonarr error I keep getting. I’m not restoring the DB. The only thing I have been doing to resolve is to reinstall Sonarr.

Try going through a DB repair, I don’t have the link handy, but I believe the wiki has the steps for that. Reinstalling shouldn’t do anything, but also the fact that some framework config file is corrupt leads me to believe there is something bigger at play.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.