Sonarr - attempt to write a readonly database

Creating a bug report/issue

Required Information

  • DietPi version
    G_DIETPI_VERSION_CORE=8
    G_DIETPI_VERSION_SUB=13
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’
    G_LIVE_PATCH_STATUS[0]=‘not applied’
    G_LIVE_PATCH_STATUS[1]=‘not applicable’

  • Distro version: bullseye

  • Kernel version: Linux DietPi 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64 GNU/Linux

  • SBC model: Native PC (x86_64)

Additional Information (if applicable)

  • Software title: Sonarr
  • Was the software title installed freshly or updated/migrated? Nope
  • Can this issue be replicated on a fresh installation of DietPi? Probably not

Steps to reproduce

  1. Go in Sonarr
  2. Delete TV show

Expected behaviour

  • TV Show should be deleted

Actual behaviour

  • TV Show not deleted, go an error “attempt to write a readonly database” instead

Extra details

Log:

2023-01-27 23:23:06.9|Fatal|SonarrErrorPipeline|Request Failed. DELETE /api/v3/series/528

[v3.0.9.1549] code = ReadOnly (8), message = System.Data.SQLite.SQLiteException (0x800017FF): attempt to write a readonly database
attempt to write a readonly database
  at System.Data.SQLite.SQLite3.Reset (System.Data.SQLite.SQLiteStatement stmt) [0x00088] in <cf516e4846354910b3d60749c894b1bf>:0 
  at System.Data.SQLite.SQLite3.Step (System.Data.SQLite.SQLiteStatement stmt) [0x0006e] in <cf516e4846354910b3d60749c894b1bf>:0 
  at System.Data.SQLite.SQLiteDataReader.NextResult () [0x00174] in <cf516e4846354910b3d60749c894b1bf>:0 
  at System.Data.SQLite.SQLiteDataReader..ctor (System.Data.SQLite.SQLiteCommand cmd, System.Data.CommandBehavior behave) [0x0008e] in <cf516e4846354910b3d60749c894b1bf>:0 
  at (wrapper remoting-invoke-with-check) System.Data.SQLite.SQLiteDataReader..ctor(System.Data.SQLite.SQLiteCommand,System.Data.CommandBehavior)
  at System.Data.SQLite.SQLiteCommand.ExecuteReader (System.Data.CommandBehavior behavior) [0x0000c] in <cf516e4846354910b3d60749c894b1bf>:0 
  at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery (System.Data.CommandBehavior behavior) [0x00006] in <cf516e4846354910b3d60749c894b1bf>:0 
  at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery () [0x00006] in <cf516e4846354910b3d60749c894b1bf>:0 
  at Marr.Data.DataMapper.Delete[T] (System.String tableName, System.Linq.Expressions.Expression`1[TDelegate] filter) [0x00099] in <1628973b989b4f8897253ac4b82f859a>:0 
  at Marr.Data.DataMapper.Delete[T] (System.Linq.Expressions.Expression`1[TDelegate] filter) [0x00000] in <1628973b989b4f8897253ac4b82f859a>:0 
  at NzbDrone.Core.Datastore.BasicRepository`1[TModel].Delete (System.Int32 id) [0x00075] in <0b43b6e47ef8497b83f58230dd1ec559>:0 
  at NzbDrone.Core.Tv.SeriesService.DeleteSeries (System.Int32 seriesId, System.Boolean deleteFiles, System.Boolean addImportListExclusion) [0x0000d] in <0b43b6e47ef8497b83f58230dd1ec559>:0 
  at Sonarr.Api.V3.Series.SeriesModule.DeleteSeries (System.Int32 id) [0x00024] in <70c417d3db7e443cad1885ec15785c44>:0 
  at Sonarr.Http.REST.RestModule`1[TResource].<set_DeleteResource>b__27_0 (System.Object options) [0x00136] in <ceae54f54b6b49648c282976bac9e575>:0 
  at Nancy.NancyModule+<>c__DisplayClass8_0`1[T].<Delete>b__0 (System.Object args) [0x00047] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.NancyModule+<>c__DisplayClass10_0`1[T].<Delete>b__0 (System.Object args, System.Threading.CancellationToken ct) [0x00047] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.Routing.Route`1[T].Invoke (Nancy.DynamicDictionary parameters, System.Threading.CancellationToken cancellationToken) [0x00017] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.Routing.DefaultRouteInvoker.Invoke (Nancy.Routing.Route route, System.Threading.CancellationToken cancellationToken, Nancy.DynamicDictionary parameters, Nancy.NancyContext context) [0x00086] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.Routing.DefaultRequestDispatcher.Dispatch (Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken) [0x002b7] in <e31b230dbd29407fadcc55713e0bbd0f>:0 
  at Nancy.NancyEngine.InvokeRequestLifeCycle (Nancy.NancyContext context, System.Threading.CancellationToken cancellationToken, Nancy.Bootstrapper.IPipelines pipelines) [0x0011d] in <e31b230dbd29407fadcc55713e0bbd0f>:0 

User running Sonarr:

Tried setting the folder AND the db file with 777 to test, still not working:
image

Tried renaming the sonar.db file then reloading the page. I’m getting an error and the DB file is recreated, so I know I’m using the right file.

Ok… actually another problem I have been working on for almost a week and of course I find the solution right after posting haha.

I deleted these 3 files after shutting down the Sonarr service:
image
And it seems to be working now after restarting the service. I’m not sure if it’s all 3 files that helped (and I’m actually afraid I should not have downloaded the 2 databse files), but I have a feeling it’s the sonarr.pid file that was in use before my computer lost power, so the DB was locked by this file. I’m sure someone here will be able to correct me if I,m going in the wrong direction.