It looks like, for a few weeks now, TV show metadata has not been properly updating on my library – and in fact, previously accurate metadata seems to be disappearing (“The Office (US)” has had all episode names for years, until recently, when several seasons just show “Episode 1” etc.). Newly added media seems to have a default “originally available at” date of 1969-12-31
Manually modifying the metadata works, and seems to save through reboots/restarting the media server. “Refresh metadata” fails, and the console logs show a “database disk image malformed” error. Given that I didn’t realize this was happening until at least a week or two into things, I don’t have database backups from before this issue started occurring.
HOWEVER, I have tried database recovery – integrity check passes without issue. Vacuum, reindex, no issue. I’ve even done both a “recover” and a “dump” to recreate the database, and they all throw the same “image malformed” error when trying to “refresh metadata” for TV shows and episodes.
Interestingly, the movies library seems okay? Newly added media has proper “originally available” dates and refreshing metadata doesn’t throw any errors.
Is there anything else I can try? Is it possible this is a misleading error? Is there anything I can try to manually pull out of the database or fix or something?
Hate the idea of having to completely recreate the library and lose all history but kind of at a loss. I saw a few other folks with possibly similar issues, though many of those seemed to primarily point to docker networking, and I’m running PMS natively on MacOS.
Re-enable debug level logging. Do not enable verbose logging.
Debug is the default setting. Turning it off does not save disk space or system resources.
Settings → Server_Name → General + Show Advanced
It is an account, not server, setting. Have all your users enable it. It does not work for managed users.
Database problems only get worse. They may not affect operation today, but at some point you’ll have problems adding media or Plex Media Server may refuse to run.
Thanks! I uploaded a new logs archive to the original post. Not sure when I had debug logging disabled.
I’ve run the plexdbrepair a few times and with a few different backups. Every task the DBRepair tool performs appears to complete without any error, but the log errors remain.
Does “watch state and ratings” include ALL history, or just whether something is marked as watched or unwatched/the spot at which media has been stopped? I have smart playlists that function around “not watched in the past X months” that would be nice to maintain.
It has the date/time the media was set as watched/unwatched. It does not have complete history of when something was watched (ex: if something was watched multiple times). Also, it does not sync status of partially watched media (ex: if you’ve watched 30 minutes of a 2 hour movie).
Thanks, this will be helpful if I end up with a functional database
I guess the question is – what are next steps if none of the database recovery options seem to a) think anything is wrong in the first place and then b) craft a database that doesn’t then throw these errors on the backend?
The Plex articles around restoring from a database backup or repairing a corrupted database don’t seem to offer any insight or next steps if none of that works.
If the database cannot be repaired and the backups are also corrupt and cannot be repaired, then you’re basically out of luck (you can run with a corrupt db, but at some point it will begin to affect operations).
You delete the current db and start over.
You will have to re-create libraries, re-share with others, etc. You can use the “Move Viewstate…” steps to copy that info to the new database.
I know that’s sometimes a thing that needs doing, but it is super impractical and onerous, particularly for large libraries on servers that have existed for years, and I definitely think Plex should have a lot more clarity in their documentation around when and how it might need to happen!
I’m working on resigning myself to it, but also still a bit confused. Granted, my SQLite knowledge is not extensive, but should I expect that databases which pass all integrity checks, and are even rebuilt from .sql dumps into entirely new databases, to still be corrupt? Shouldn’t there be at least a single error in rebuilding, or in the dump, if the data itself is corrupt?
Is it possible the malformed database is one of the non-primary databases? Or is it possible to use one of the sql dumps to partially import data into a new, empty database?
Or, I wonder if it’s possible to try to insert something using the triggers via CLI similar to how Plex is doing, just so I can get to the corruption error message more directly… right now the Plex logs are the only place the error is appearing.
Is it ok if I attach the original logs from yesterday and the day before? I ran the auto-repair a couple times and a replace with a backup (despite the “everything’s ok! are you sure?” warning ) and I think that’s all captured in this log.
Thanks for your help. It would still be nice to be able to troubleshoot the database directly, otherwise I’m worried I’m risking corruption again after recreating, but it is what it is
Is there a reason database errors are so hidden in the console? I would think the “Alerts” section would be a good place to spit out metadata processing errors, but instead the alerts all seemed to think everything was fine.
I know I can (and should, etc etc) set up my own backups, but it would also be really nice to have some custom options on the backup, particularly time between backups and number of backups to hold on to.
Anyway, sincerely, thanks again for digging in on this. Luckily my Python skills are significantly better than my SQL skills so I can mess around with fixing my metadata via the API.
Database corruption usually happens when the Plex Media Server or the system is shutdown incorrectly, such as during a power failure, system crash, etc. I’m sure it can happen for other reasons too, but power fail & crash seem to be the worst offenders.
Plex Media Server can send push notifications to the mobile app. There are notifications for many events, including when database corruption is detected.
Plex Media Server Settings → General and enable Push Notifications.
In the app settings, there is a Notifications section, where specific notifications can be enabled/disabled.
Tautulli also has notification capability (and a lot of other nice features). It can send notifications to the Tautulli mobile app and to many other destinations - e-mail, Discord, Slack, etc. Definitely worth checking out.
Neat, I didn’t realize the mobile notifications had been updated to include database corruption! Now I’m curious to know if it would have alerted me soon enough to restore from backup!
…will not be testing that one (intentionally, anyway).
Aww, sad news, it looks like I already had notifications enabled for database corruption, and I have never gotten push notifications about it
I do get notifications for other events as expected — new logins, new media, etc, so I know notifications overall are working. Not sure what the threshold is for database corruption push notifications, but it seems like my errors didn’t meet it. Oh well!