"There was an unexpected error loading this item" database problem with one item

Server Version#: 1.14.1.5488
Platform: macOS 10.14.3

There’s a particular item in my library that seems to always have a problem when accessing it. Interestingly this seems to be the very first item I added to my Movies library. There’s no problem in my TV library. On the Plex web view, I get this error message when clicking on it: “There was an unexpected error loading this item. Please visit our forums if you continue to experience problems”.

I can also reproduce the same problem by running the Plex Media Scanner directly. If I run this command Plex\ Media\ Server.app/Contents/MacOS/Plex\ Media\ Scanner -c 5 --tree
It returns normal results until it encounters the corrupted item. It ends by displaying something like this:

...
* My-Corrupted-Library-Item [2016]
****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: A8FFAD6E-4EDA-4659-BEC1-B59F878C1DD6

Repairing the database multiple times as explained here does not fix the problem. Everything, in general, seems to work fine except when I try to interact with that one particular item. Sadly I can’t delete it either. All actions on this item seem to fail.

Turning on logging (not verbose logging) doesn’t seem to reveal much either. Plex Media Server.log doesn’t offer any clues. The ‘Plex Media Scanner.log’ file seems to cut out right before encountering the corrupted file. None of the other logs seems to hint at the problem either. The Scanner’s logs just shows this:

Feb 04, 2019 13:42:43.857 [0x700001144000] INFO - Plex Media Scanner v1.14.1.5488-cc260c476 - Apple Mac x86_64 - build: darwin-x86_64 - GMT -08:00
Feb 04, 2019 13:42:43.857 [0x700001144000] INFO - MacOSX version: 10.14.3, language: en-US
Feb 04, 2019 13:42:43.857 [0x700001144000] INFO - Processor Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
Feb 04, 2019 13:42:43.857 [0x700001144000] INFO - /Applications/Plex Media Server.app/Contents/MacOS/Plex Media Scanner -c 5 --tree
Feb 04, 2019 13:42:43.851 [0x114ceb5c0] WARN - Default locale is invalid; falling back on classic+UTF-8
Feb 04, 2019 13:42:43.865 [0x114ceb5c0] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.13.0, threadsafe=1

The crash dump is being uploaded to Plex’s servers directly. But I can collect one as well if that would help.

Any ideas on how to fix this? I wish I could just manually remove this item entirely from my library but not sure how. The com.plexapp.plugins.library.db schema seems pretty complex so not sure how to manually edit it to remove an item.

Would love some tips on how to fix this! Any ideas? I really don’t want to have to delete and then re-scan my entire library, but I know that would probably work as a last resort. Thanks!

I’m having the same problem. Would love to hear of a possible solution.

Server Version#: 1.14.1.5488
Platform: macOS 10.13.6

Ok I fixed this! But I had to do surgery on Plex’s sqlite library database and manually remove the bad item. This isn’t an elegant solution but might help you rkingston.

After shutting down Plex and making sure the database was all backed up, in Plex’s com.plexapp.plugins.library.db database you just need to delete the row corresponding to the bad item. This command on the terminal does it:
sqlite3 com.plexapp.plugins.library.db "DELETE FROM metadata_items WHERE id=<BAD_IT_ID>". You can also us a GUI program like “DB Browser for Sqlite”.
Before doing this you must also perform the whole repair a corrupt database operation but DO NOT RUN Plex. If you run Plex it will re-apply migrations and build indexes you don’t want. Importantly this process drops the index_title_sort_naturalsort index which needs to happen first otherwise you’ll get an error when you try to delete the bad row in metadata_items.

Some tips:

  • I also tried to delete some other references to the bad media item ID I found in other tables (play_queue_items, media_items) but a little bit of testing makes me think that’s not necessary. (Plex should be smart enough to assume something is delete if its ID missing from metadata_items?)
  • You need to know the bad item’s media ID to know what to delete. There are ways to get this in a webapp but since we’re messing with the database anyway, just go to your Plex database directory and run this sqlite command from your terminal:
    ➜ sqlite3 com.plexapp.plugins.library.db "SELECT title,id FROM metadata_items WHERE title LIKE '%NAME_OF_BAD_THING%'"
    That looks at the title and ID of everything in your library and then filters based on the matching title. (Fixed per Otto’s feedback!)
  • Be extra sure to back up your database. If you mess up this database surgery Plex will have problems and you’ll need to shutdown Plex and restore the backed up database files. Since you need to go through Plex’s “repair a corrupt database” guide first you’ll already have an understanding of what these files mean and how to back them up. You should be trying that solution first beforehand anyway.

It’s been a while since I dabbled in SQL, but wouldn’t this work as well?
With the added benefit that it will also work on systems which don’t have grep.
➜ sqlite3 com.plexapp.plugins.library.db "SELECT title,id FROM metadata_items WHERE title LIKE '%NAME_OF_BAD_THING%'"

Disclaimer: I haven’t actually tested this. The % characters may work or may not work in SQLite.

hah that’s a great point about not everyone having grep…I edited my comment to include your improvement! If I was really awesome I’d put in all the commands needed to remove the bad rows with just sqlite commands but maybe I’ll save that for another day =P

Moi cest marqué une erreur est survenu lord du chargement du tableau de bord comment le regler

Update:

This solution works but has some side effects. Even though this fixes the problem and removes the bad media item’s ID from the database and Plex’s library listing, it doesn’t properly reset all state related to this item. In particular Plex still tracks the directory the media was in the library’s directories table so when I try to scan the directory again after deleting the item, Plex doesn’t scan it. I could also try to remove those rows from the directories table and more properly erase any trace of this piece of media…but that might be a trickier problem. Instead I just renamed the directory this media was in and had Plex re-scan this new directory and it added it back to my library just fine.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.