Database Corrupted and fixing it kills PMS

Server Version#: Version 1.15.1.710

Error Message:

Page 71770: btreeInitPage() returns error code 11
Error: database disk image is malformed

I did a big rearrange of my media, and in the process my database ended up getting corrupted. As a result, the database would not sort movies by Title (but other sorts would show up the movies).

Using the instructions at https://support.plex.tv/articles/201100678-repair-a-corrupt-database/ , I first did a check of the database, and yeah, it came back corrupted. See above.

I then did the step by step for repair.

Then, when I went to restart Plex, it won’t restart. I click on the app and I see the icon flash in the menu bar and then disappear. Tried a system restart, still won’t work.

I did a time machine restore of the whole folder at ~/Library/Application Support/Plex Media Server/Plug-in Support/Databases/

That got Plex running again, but obviously with the same problem of sorting by title.

I tried following the instructions again, and had the same result.

So after another TM restore of the folder, I am left at a loss. Any idea how to fix the database?? Any ideas how to fix my database? Following the directions at the above link ended up nuking my system, and I really don’t want to have to rebuild my entire database from scratch again, and lose all of my posters, collection data, etc.

Help!

Restore (and repair!) one of the backup versions of the database.
https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/

The problem is with the repair process. From doing some more research, it seems that the Mac instructions are missing a step…but I don’t understand how to do the missing step detailed in this post:

No, it’s not missing a step. It should work exactly as written.
Which error do you get at which step?

Not exactly sure…I think it is: Error: no such index: index_title_sort_naturalsort"

To help you help me ( :slight_smile:), I re did everything again this morning.

First I shut down PMS.

Then I did the check database steps, and here is what happens on terminal:

Andrews-iMac:~ ajablon$ cd ~/Library/Application\ Support/Plex\ Media\ Server/Plug-in\ Support/Databases/

Andrews-iMac:Databases ajablon$ cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db “DROP index ‘index_title_sort_naturalsort’”

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db “DELETE from schema_migrations where version=‘20180501000000’”

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db “PRAGMA integrity_check”

*** in database main ***

Page 71770: btreeInitPage() returns error code 11

Error: database disk image is malformed

Andrews-iMac:Databases ajablon$


Then I did the repair steps, and this is what happens in terminal:

Andrews-iMac:Databases ajablon$ cp com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db “DROP index ‘index_title_sort_naturalsort’”

Error: no such index: index_title_sort_naturalsort

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db “DELETE from schema_migrations where version=‘20180501000000’”

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db .dump > dump.sql

Andrews-iMac:Databases ajablon$ rm com.plexapp.plugins.library.db

Andrews-iMac:Databases ajablon$ sqlite3 com.plexapp.plugins.library.db < dump.sql

Then, per the instructions, I deleted

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

Then I restarted PMS (clicked on the app)

And same problem. Won’t start. The PMS icon in the menu bar flashes, and then nothing. (Although two new -shm and -wal files got created when I clicked on PMS).

Any ideas?

If it helps, I did a DL of my logs.

Plex Media Server Logs_2019-03-02_07-25-55.zip (2.3 MB)

I can also to a DL of the database and upload that if that helps.

There is no step missing, but you performed 2 steps twice. The error message Error: no such index: index_title_sort_naturalsort resulting from that is inconsequential.

It is clear now that the database file which you used for the repair process is damaged beyond repair.

Have you tried those same repair steps on one of the backup copies of the database?

Not yet. I did what you said to replace the db with an older backup. Plex will again sort by Title when I used that DB, but it is obviously outdated because of the massive re-arrange I did of my movies and tv shows. The server is currently updating to reflect that massive re-arrange. (Unfortunately, I obviously lost the stuff I did with my collections tags from post backup date.)

Q: Once that is done, assuming it is still sorting correctly and not having the problem I had before, should I still run a check and repair on the DB, or leave well enough alone?

Q: Did I screw up? Should I have run the repair on the backup db before letting PMS update?

Q: Why would the repair process result in a Plex just not starting at all? Is that a function of the repair just nuking an already too corrupt DB?

Yes, better safe than sorry.

Not really. But it would’ve been better to verify the integrity of the backup file before doing a massive update.

It is the result of an un-repairable database. The repair procedure is not guaranteed to be successful in all cases. Sometimes the damage is just too extensive.

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