TrimLogCommand Error

Hi there,

I’am using Sonarr for a while now but sometimes it crashes at random moment (as far as I can see). When I restart Sonarr and it works for a while before crashing again. So i have looked at the log files and found the following problem.

15-5-3 13:52:07.4|Info|EpisodeSearchService|Completed search for 3 episodes. 3 reports downloaded.
15-5-3 14:08:34.2|Info|RssSyncService|Starting RSS Sync
15-5-3 14:08:37.6|Info|DownloadDecisionMaker|Processing 6 reports
15-5-3 14:08:39.0|Info|RssSyncService|RSS Sync Completed. Reports found: 6, Reports grabbed: 0
15-5-3 14:23:45.8|Info|RssSyncService|Starting RSS Sync
15-5-3 14:23:46.0|Info|DownloadDecisionMaker|Processing 6 reports
15-5-3 14:23:46.2|Info|RssSyncService|RSS Sync Completed. Reports found: 6, Reports grabbed: 0
15-5-3 14:38:52.9|Info|RssSyncService|Starting RSS Sync
15-5-3 14:38:53.2|Info|DownloadDecisionMaker|Processing 13 reports
15-5-3 14:38:53.3|Info|RssSyncService|RSS Sync Completed. Reports found: 13, Reports grabbed: 0
15-5-3 14:51:59.7|Error|Scheduler|Error occurred while executing task NzbDrone.Core.Instrumentation.Commands.TrimLogCommand

System.Data.SQLite.SQLiteException: database disk image is malformed
database disk image is malformed
at System.Data.SQLite.SQLite3.Reset (System.Data.SQLite.SQLiteStatement stmt) [0x00000] in :0
at System.Data.SQLite.SQLite3.Step (System.Data.SQLite.SQLiteStatement stmt) [0x00000] in :0
at System.Data.SQLite.SQLiteDataReader.NextResult () [0x00000] in :0
at System.Data.SQLite.SQLiteDataReader…ctor (System.Data.SQLite.SQLiteCommand cmd, CommandBehavior behave) [0x00000] in :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 (CommandBehavior behavior) [0x00000] in :0
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery (CommandBehavior behavior) [0x00000] in :0
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery () [0x00000] in :0
at Marr.Data.DataMapper.Delete[Log] (System.String tableName, System.Linq.Expressions.Expression1 filter) [0x00000] in <filename unknown>:0 at Marr.Data.DataMapper.Delete[Log] (System.Linq.Expressions.Expression1 filter) [0x00000] in :0
at NzbDrone.Core.Datastore.BasicRepository1[NzbDrone.Core.Instrumentation.Log].Delete (System.Linq.Expressions.Expression1 filter) [0x00000] in :0
at NzbDrone.Core.Instrumentation.LogRepository.Trim () [0x00000] in :0
at NzbDrone.Core.Instrumentation.LogService.Execute (NzbDrone.Core.Instrumentation.Commands.TrimLogCommand message) [0x00000] in :0
at NzbDrone.Core.Messaging.Commands.CommandExecutor.ExecuteCommand[TrimLogCommand] (NzbDrone.Core.Messaging.Commands.Command command) [0x00000] in :0

15-5-3 14:54:00.1|Info|RssSyncService|Starting RSS Sync
15-5-3 14:54:00.3|Info|DownloadDecisionMaker|Processing 13 reports
15-5-3 14:54:00.4|Info|RssSyncService|RSS Sync Completed. Reports found: 13, Reports grabbed: 0
15-5-3 15:09:05.8|Info|RssSyncService|Starting RSS Sync
15-5-3 15:09:06.0|Info|DownloadDecisionMaker|Processing 13 reports
15-5-3 15:09:06.1|Info|RssSyncService|RSS Sync Completed. Reports found: 13, Reports grabbed: 0
15-5-3 15:24:11.5|Info|RssSyncService|Starting RSS Sync
15-5-3 15:24:11.7|Info|DownloadDecisionMaker|Processing 13 reports
15-5-3 15:24:11.9|Info|RssSyncService|RSS Sync Completed. Reports found: 13, Reports grabbed: 0
15-5-3 15:39:16.7|Info|RssSyncService|Starting RSS Sync
15-5-3 15:39:17.2|Info|DownloadDecisionMaker|Processing 3 reports
15-5-3 15:39:17.2|Info|RssSyncService|RSS Sync Completed. Reports found: 3, Reports grabbed: 0
15-5-3 15:52:21.6|Error|Scheduler|Error occurred while executing task NzbDrone.Core.Instrumentation.Commands.TrimLogCommand

System.Data.SQLite.SQLiteException: database disk image is malformed
database disk image is malformed
at System.Data.SQLite.SQLite3.Reset (System.Data.SQLite.SQLiteStatement stmt) [0x00000] in :0
at System.Data.SQLite.SQLite3.Step (System.Data.SQLite.SQLiteStatement stmt) [0x00000] in :0
at System.Data.SQLite.SQLiteDataReader.NextResult () [0x00000] in :0
at System.Data.SQLite.SQLiteDataReader…ctor (System.Data.SQLite.SQLiteCommand cmd, CommandBehavior behave) [0x00000] in :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 (CommandBehavior behavior) [0x00000] in :0
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery (CommandBehavior behavior) [0x00000] in :0
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery () [0x00000] in :0
at Marr.Data.DataMapper.Delete[Log] (System.String tableName, System.Linq.Expressions.Expression1 filter) [0x00000] in <filename unknown>:0 at Marr.Data.DataMapper.Delete[Log] (System.Linq.Expressions.Expression1 filter) [0x00000] in :0
at NzbDrone.Core.Datastore.BasicRepository1[NzbDrone.Core.Instrumentation.Log].Delete (System.Linq.Expressions.Expression1 filter) [0x00000] in :0
at NzbDrone.Core.Instrumentation.LogRepository.Trim () [0x00000] in :0
at NzbDrone.Core.Instrumentation.LogService.Execute (NzbDrone.Core.Instrumentation.Commands.TrimLogCommand message) [0x00000] in :0
at NzbDrone.Core.Messaging.Commands.CommandExecutor.ExecuteCommand[TrimLogCommand] (NzbDrone.Core.Messaging.Commands.Command command) [0x00000] in :0

This is from the log file.
I am running Ubuntu Server version 14.04.2 LTS

Any solutions?

Delete logs.db from Sonarr’s App Data folder, it is corrupt.

The crashing is probably related to: Native mono crashes [kernel fix released] though.

Thanks for your reaction. I have deleted the logs.db file from the Sonarr’s app data folder.

Now after some time this appears in the webUI

{
“message”: “unable to open database file”,
“description”: "System.Data.SQLite.SQLiteException: unable to open database file\n at System.Data.SQLite.SQLite3.Open (System.String strFilename, SQLiteConnectionFlags connectionFlags, SQLiteOpenFlagsEnum openFlags, Int32 maxPoolSize, Boolean usePool) [0x00000] in :0 \n at System.Data.SQLite.SQLiteConnection.Open () [0x00000] in :0 "
}

is this related?

Where in the UI does that appear?

Thats the same error though, a corrupt DB, either the logs DB again or nzbdrone.db.

It does appear when i go to the browser page (SERVERIP:8989).

The files that are in /home/USER/.config/Nzbdorne are,

Backups config.xml logs logs.db logs.db-shm logs.db-wal MediaCover nzbdrone.db nzbdrone.db-shm nzbdrone.db-wal nzbdrone.pid

I have removed logs.db again. Can i also try to remove the logs.db-shm and the logs.db-wal files?
What happens when I remove the nzbdrone.db file?

Thanks

Yes, those files work along side logs.db to prevent most errors from corrupting the DB.

That contains all your settings and series information, you don’t want to remove that unless you know its the issue.

What errors do you see in the log files?

so now I have removed all the log.db* files.

There was 1 error in the logs I could find so quickly.

15-5-7 20:51:29.1|Error|Scheduler|Error occurred while executing task NzbDrone.Core.Instrumentation.Commands.TrimLogCommand

System.Data.SQLite.SQLiteException: SQL logic error or missing database
no such table: Logs
at System.Data.SQLite.SQLite3.Prepare (System.Data.SQLite.SQLiteConnection cnn, System.String strSql, System.Data.SQLite.SQLiteStatement previous, UInt32 timeoutMS, System.String& strRemain) [0x00000] in :0
at System.Data.SQLite.SQLiteCommand.BuildNextCommand () [0x00000] in :0

15-5-7 21:02:03.4|Info|RssSyncService|Starting RSS Sync

Today the server ran out of free space so there are also lot of warnings about that in the logs

Looks like the DB was corrupt again, possibly from running out of space if it was in the middle of a write.