Sonarr Database Corruption?

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version | Recent as of 2 months ago but not latest.

Additional Information (if applicable)

  • Sonarr v3
  • Sonarr wasn’t recently updated

Actual behaviour

I got the :

"description": "code = CantOpen (14), message = System.Data.SQLite.SQLiteException (0x800007FF): unable to open database file\nunable to open database file\n  at System.Data.SQLite.SQLite3.

I’m guessing database is corrupt? I’m running Sonarr on a Rasp Pi 4 on Dietpi.

Is the best course to uninstall the app, (reboot) reinstall Sonarr app, then restore from (likely 6 month old) backup?

Extra details

Sonarr has been running fine for months, and this just randomly happened. Have rebooted the Pi several times, but when I try to access the app via browser, I just get the error above (full below).

"message": "unable to open database file\nunable to open database file",
  "description": "code = CantOpen (14), message = System.Data.SQLite.SQLiteException (0x800007FF): unable to open database file\nunable to open database file\n  at System.Data.SQLite.SQLite3.Prepare (System.Data.SQLite.SQLiteConnection cnn, System.String strSql, System.Data.SQLite.SQLiteStatement previous, System.UInt32 timeoutMS, System.String& strRemain) [0x003d3] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at System.Data.SQLite.SQLiteCommand.BuildNextCommand () [0x000f6] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at System.Data.SQLite.SQLiteCommand.GetStatement (System.Int32 index) [0x00008] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteCommand.GetStatement(int)\n  at System.Data.SQLite.SQLiteDataReader.NextResult () [0x00124] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at System.Data.SQLite.SQLiteDataReader..ctor (System.Data.SQLite.SQLiteCommand cmd, System.Data.CommandBehavior behave) [0x0008e] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteDataReader..ctor(System.Data.SQLite.SQLiteCommand,System.Data.CommandBehavior)\n  at System.Data.SQLite.SQLiteCommand.ExecuteReader (System.Data.CommandBehavior behavior) [0x0000c] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery (System.Data.CommandBehavior behavior) [0x00006] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery () [0x00006] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at System.Data.SQLite.SQLiteConnection.Open () [0x00a13] in \u003Ccf516e4846354910b3d60749c894b1bf\u003E:0 \n  at Marr.Data.DataMapper.OpenConnection () [0x00024] in \u003C83eb267e1f914726a4824125d3294f2b\u003E:0 \n  at Marr.Data.DataMapper.Query[T] (System.String sql, System.Collections.Generic.ICollection`1[T] entityList, System.Boolean useAltName) [0x00065] in \u003C83eb267e1f914726a4824125d3294f2b\u003E:0 \n  at Marr.Data.QGen.QueryBuilder`1[T].ToList () [0x00052] in \u003C83eb267e1f914726a4824125d3294f2b\u003E:0 \n  at Marr.Data.QGen.SortBuilder`1[T].ToList () [0x00000] in \u003C83eb267e1f914726a4824125d3294f2b\u003E:0 \n  at Marr.Data.QGen.SortBuilder`1[T].GetEnumerator () [0x00000] in \u003C83eb267e1f914726a4824125d3294f2b\u003E:0 \n  at System.Linq.Enumerable.SingleOrDefault[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0003a] in \u003C69ada62907b24213a012734531df1db1\u003E:0 \n  at NzbDrone.Core.Authentication.UserRepository.FindUser (System.String username) [0x00075] in \u003C36de8bde5c044e5c81a2ebe2e2feff11\u003E:0 \n  at NzbDrone.Core.Authentication.UserService.FindUser (System.String username, System.String password) [0x0001e] in \u003C36de8bde5c044e5c81a2ebe2e2feff11\u003E:0 \n  at Sonarr.Http.Authentication.AuthenticationService.Login (Nancy.NancyContext context, System.String username, System.String password) [0x00009] in \u003C12236ccfa32a406eaecf71770d39a2d3\u003E:0 \n  at Sonarr.Http.Authentication.AuthenticationModule.Login (Sonarr.Http.Authentication.LoginResource resource) [0x00018] in \u003C12236ccfa32a406eaecf71770d39a2d3\u003E:0 \n  at Sonarr.Http.Authentication.AuthenticationModule.\u003C.ctor\u003Eb__2_0 (System.Object x) [0x00007] in \u003C12236ccfa32a406eaecf71770d39a2d3\u003E:0 \n  at Nancy.NancyModule+\u003C\u003Ec__DisplayClass38_0`1[T].\u003CPost\u003Eb__0 (System.Object args) [0x00047] in \u003Ce31b230dbd29407fadcc55713e0bbd0f\u003E:0 \n  at Nancy.NancyModule+\u003C\u003Ec__DisplayClass40_0`1[T].\u003CPost\u003Eb__0 (System.Object args, System.Threading.CancellationToken ct) [0x00047] in \u003Ce31b230dbd29407fadcc55713e0bbd0f\u003E:0 \n  at Nancy.Routing.Route`1[T].Invoke (Nancy.DynamicDictionary parameters, System.Threading.CancellationToken cancellationToken) [0x00017] in \u003Ce31b230dbd29407fadcc55713e0bbd0f\u003E:0 \n  at Nancy.Routing.DefaultRouteInvoker.Invoke (Nancy.Routing.Route route, System.Threading.CancellationToken cancellationToken, Nancy.DynamicDictionary parameters, Nancy.NancyContext context) [0x00086] in \u003Ce31b230dbd29407fadcc55713e0bbd0f\u003E:0 \n  at Nancy.Routing.DefaultRequestDispatcher.Dispatch (Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken) [0x002b7] in \u003Ce31b230dbd29407fadcc55713e0bbd0f\u003E:0 \n  at Nancy.NancyEngine.InvokeRequestLifeCycle (Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken, Nancy.Bootstrapper.IPipelines pipelines) [0x0011d] in \u003Ce31b230dbd29407fadcc55713e0bbd0f\u003E:0 "
}


This will install Sonarr v4

what kind of backup you like to restore?

It would be a backup of V3, mostly so I don’t have to recreate profiles, quality settings, and all that stuff. But like I said, it’s likely 6 months old. I did get another link from someone else on a possible database recovery set of commands.

Have you had a look in to this:
Upgrading Sonarr V3 to V4
Did you try to reinstall it with dietpi-software to migrate the db?

the SQLlite file is already corrupted/missing on v3. Not sure if an update to v4 is working in this case.