Why do I get this message?- There was an unexpected error loading this library

Hi,

I can’t see my movie files, artwork, and metadata, and I get this message “There was an unexpected error loading this library” How can I fix this? I have scanned my library files, optimized my database, cleaned my bundles, and emptied my trash several times but keep seeing this message. I need some help.

Thanks in advance. Have a great day.

  1. activate debug logging (not ‘verbose’!)
  2. quit Plex Server
  3. wait 1 minute
  4. start Plex Server
  5. wait 5 minutes
  6. fetch log files and attach them here

Or inspect them yourself. Take a look at the Plex Media Server.log file and seek for messages about database corrupt or malformed.
If you find these, you may have to repair your database.

Please report back for an updated repair procedure.

Hi,

I’m running Plex version 1.13.0.5023 and Mac OS 10.11.6

Let me know if you need anymore info. Thanks in advance for your help.

Yes, unfortunately the database file is damaged.

Jun 04, 2018 10:21:27.119 [0x700001177000] ERROR - SQLITE3:0x7000006b7590, 11, database corruption at line 59739 of [fc49f556e4]
Jun 04, 2018 10:21:27.119 [0x700001177000] ERROR - SQLITE3:0x7000006b7590, 11, statement aborts at 83: [select distinct media_items.id as 'media_items_id', media_items.library_section_id as 'media_items_library_section_id', media_items.section_location_id as 'media_items_section_location
Jun 04, 2018 10:21:27.123 [0x700001177000] ERROR - Soci Exception handled: sqlite3_statement_backend::loadRS: database disk image is malformed

Are you comfortable with the terminal?
The repair procedure involves copy&paste’ing several commands.

Make sure you quit/exit your Plex Media Server so that it is not running. The following commands are run in the Terminal application. When running the commands, you need to escape any spaces in paths.

##1) First, simply switch over to the directory containing the database.

cd ~/Library/Application Support/Plex Media Server/Plug-in Support/Databases/

##2) Remove a certain index table which will otherwise cause the integrity check to abort.

sqlite3 com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"

sqlite3 com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"

It is of utmost importance, that the above commands are copied exactly as written, because they alter the database directly.

##3) Now run the integrity check

sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"

And then attempt repair
##4) export the DB to SQL file:

sqlite3 com.plexapp.plugins.library.db .dump > dump.sql 

##5) Now rename the original, corrupted DB file

mv com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original

##6) reimport the SQL dump back into a new DB file:

sqlite3 com.plexapp.plugins.library.db < dump.sql

##7) Run another check to establish if repair was successful

sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"

If the last check was successful, you can now start Plex Server again.

Ok. Thanks. If I don’t understand it or know how to do it I’ll try to find someone nearby that does.

Or do you know if there is a YouTube video that shows how to do it?

@“Mr. T32” said:
Or do you know if there is a YouTube video that shows how to do it?

Not to my knowledge, sorry!

I could give it a try if you are OK with sending me the files

com.plexapp.plugins.library.db
com.plexapp.plugins.library.db-shm
com.plexapp.plugins.library.db-wal

(zip them beforehand, please)

I’ve never used terminal before so i don’t have a clue on what to do. Is there another way of fixing the problem without using terminal?

Unfortunately not, sorry.

Well. I signed out of my server then I deleted all of my com.plexapp.plugins.library.db database files. Then signed back in to my server and created my libraries again. It seems to be working. Thanks for all of the advice. I truly appreciated it. Have a great day!