cjmanca / plex-credits-detect

Augments plex's built in intro detection, additionally detecting credits.
MIT License
113 stars 5 forks source link

`PlexDB ExecuteDBCommand SQLite error code 11: database disk image is malformed` #13

Closed KnifeFed closed 2 years ago

KnifeFed commented 2 years ago

I just ran the script for the first time, and it seemed to be chugging along fine, but when checking the logs after an hour or so it just says PlexDB ExecuteDBCommand SQLite error code 11: database disk image is malformed repeated over and over. If I restart the Docker container I get:

log ``` today at 1:42:49 AM Loading global config file: /config/plex-credits-detect/fingerprint.ini today at 1:42:49 AM today at 1:42:49 AM Syncing newly added episodes from plex... today at 1:42:49 AM today at 1:42:49 AM Found changed directories: 0 today at 1:42:49 AM today at 1:42:49 AM today at 1:42:49 AM Compiling list of pending seasons... today at 1:42:49 AM today at 1:42:49 AM today at 1:42:49 AM Processing season 1 of 278: /tv/Show Name (2022)/Season 01 today at 1:42:49 AM today at 1:42:49 AM Fingerprinting: /Show Name (2022)/Season 01/Show Name (2022) - S01E01 - Episode Name.mkv (0:49:04.68 - 0:59:04.68) today at 1:42:53 AM Fingerprinting: /Show Name (2022)/Season 01/Show Name (2022) - S01E02 - Episode Name.mkv (0:47:51.36 - 0:57:51.36) today at 1:42:56 AM Fingerprinting: /Show Name (2022)/Season 01/Show Name (2022) - S01E03 - Episode Name.mkv (0:48:03.8 - 0:58:03.8) today at 1:42:59 AM Fingerprinting: /Show Name (2022)/Season 01/Show Name (2022) - S01E04 - Episode Name.mkv (0:48:15.76 - 0:58:15.76) today at 1:43:03 AM Fingerprinting: /Show Name (2022)/Season 01/Show Name (2022) - S01E05 - Episode Name.mkv (0:47:45.52 - 0:57:45.52) today at 1:43:06 AM today at 1:43:06 AM Detecting: /Show Name (2022)/Season 01/Show Name (2022) - S01E03 - Episode Name.mkv today at 1:43:07 AM today at 1:43:07 AM Detecting: /Show Name (2022)/Season 01/Show Name (2022) - S01E04 - Episode Name.mkv today at 1:43:13 AM Audio credits match from 3456.80 to 3491.92. Duration: 35.11. today at 1:43:14 AM Match from 3456.80 to 3491.92. Duration: 35.11. today at 1:43:14 AM PlexDB ExecuteDBCommand SQLite error code 11: database disk image is malformed ```

Does this mean my Plex DB got malformed all of a sudden (everything still seems to be working fine in Plex) or is it fingerprintMedia.db that's malformed?

cjmanca commented 2 years ago

It's indicating an issue with your plex database. I'd suggest following plex's guide to repairing the plex database: https://support.plex.tv/articles/repair-a-corrupted-database/

Apps can potentially work with partially corrupted databases for a long time in some cases (which is why plex still seems fine). SQLite has a lot of safeguards to try to help protect against complete failure with a corrupted database. But that doesn't mean that everything is ok. It's possible that the malformed issue has been there for weeks or months and you just weren't aware of it. Plex isn't very good at informing people about database corruption.

What operating system are you using? Also, just to verify - is both this utility and the plex media server being run on the same machine?

KnifeFed commented 2 years ago

everything still seems to be working fine in Plex

^Scratch that. Plex was working perfectly fine and then after having plex-credits-detect run for a while these errors showed up and PMS was completely dead, i.e. I couldn't even access it from the web interface and only got this in the log:

2022-08-07 02:09:42,908 DEBG fd 8 closed, stopped monitoring <POutputDispatcher at 23187323878704 for <Subprocess at 23187322226000 with name plexmediaserver in state STARTING> (stdout)>
2022-08-07 02:09:42,908 DEBG fd 10 closed, stopped monitoring <POutputDispatcher at 23187322231328 for <Subprocess at 23187322226000 with name plexmediaserver in state STARTING> (stderr)>
2022-08-07 02:09:42,909 INFO exited: plexmediaserver (exit status 255; not expected)
2022-08-07 02:09:42,909 DEBG received SIGCHLD indicating a child quit
2022-08-07 02:09:45,912 INFO spawned: 'plexmediaserver' with pid 82
2022-08-07 02:09:45,969 DEBG 'plexmediaserver' stdout output:
Error: Unable to set up server: sqlite3_statement_backend::loadOne: database disk image is malformed (N4soci10soci_errorE)

So I'd definitely say that plex-credits-detect was the cause, but perhaps indirectly. Do you have any safeguards in place for if e.g. the container gets stopped/restarted mid-operation or something like that? The first time I ran it, it started checking all my libraries, which I didn't want, so I shut the container down, edited the config file, and then started it again. That's when everything seemed to chug along fine with credit detection, until after a while when I noticed I could no longer access PMS and then saw all the database disk image is malformed messages in the log. Maybe the DB got borked when I shut the container down? I wanted to go back and check the logs for when exactly the errors first appeared but there are no log files in the config directory and the Docker log doesn't go that far back since this error gets output ~200 times per second.

What operating system are you using? Also, just to verify - is both this utility and the plex media server being run on the same machine?

Latest Unraid, hosting both containers.

cjmanca commented 2 years ago

SQLite itself has safeguards in the case of interrupted actions, but yes - plex-credits-detect is designed to be able to be shut down at any point and continue from where it was when launched again after.

I'd suggest restoring from a backup prior to starting and do the database repair on the plex DB before launching plex-credits-detect on the fresh database.

I'd suggest updating the the most recent version too, since there have been a couple of bug fixes. It also now shuts down if there's an SQL error (which isn't part of normal operations) rather than trying to continue.

KnifeFed commented 2 years ago

I did restore and checked for database corruption, but there was none. I'll try running plex-credits-detect again in the week and report back.

cjmanca commented 2 years ago

Stale issue, closing until I hear more