Plex server doesn't start

My Plex server doesn’t start anymore. Looking at the log file I can see these issues:

Jul 19, 2018 17:08:52.406 [0x146823144800] DEBUG - BPQ: [Idle] -> [Starting]
Jul 19, 2018 17:08:52.408 [0x146823144800] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.13.0, threadsafe=1
Jul 19, 2018 17:08:52.409 [0x146823144800] INFO - SQLITE3:0x10, 283, recovered 23 frames from WAL file /config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db-wal
Jul 19, 2018 17:08:52.454 [0x146823144800] DEBUG - Running migrations.
Jul 19, 2018 17:08:52.459 [0x146823144800] ERROR - SQLITE3:0x10, 11, database corruption at line 59717 of [fc49f556e4]
Jul 19, 2018 17:08:52.459 [0x146823144800] ERROR - SQLITE3:0x10, 11, statement aborts at 10: [select max(max(metadata_items.changed_at),max(metadata_items.resources_changed_at)) from metadata_items] database disk image is malformed
Jul 19, 2018 17:08:52.459 [0x146823144800] ERROR - Database corruption: sqlite3_statement_backend::loadOne: database disk image is malformed
Jul 19, 2018 17:08:52.459 [0x146823144800] ERROR - Error: Unable to set up server: sqlite3_statement_backend::loadOne: database disk image is malformed (N4soci10soci_errorE)

Trying to check or repair the database with SQLite3 didn’t work either - the error there is “No such collation sequence: naturalsort”

Unfortunately, I don’t have a database backup to restore.

Any idea what’s going on here? And how I can get my server back to normal?

Thanks very much for your help!

If the database is that corrupt, and you don’t have a backup image you can use, you have no choice but to wipe it out and start over.

It might be prudent to:

a) set the Scheduled Tasks to run when you know the server will be running
b) make certain backing up the database every 3 days is enabled

Have problem with server too

Really? There is no way to edit the database to remove the offending ‘line’ 59717? And what does ‘no such collation sequence: naturalsort’ mean?

I also tried dumping the data and then re-creating the database as suggested elsewhere but the re-import fails with these errors:

Error: near line 1619804: UNIQUE constraint failed: taggings.id
Error: near line 2117662: no such collation sequence: naturalsort

Any idea what this means and why this is happening?

Can I not delete less vital parts of the database and keep the rest? Like metadata for example I can re-scan and re-downlaod…

I’m not a database expert at all but I’d like to do whatever I can to salvage the database - starting all over would mean many hours of work.

If you’re hoping to salvage your watched status, that’s doable.
naturalsort in the Plex database is a plex-proprietary attribute and why you’re having difficulty with it.
It was recently implemented and engineering is still refining things in PMS . I do not know the status of that work so have no further details on it.

If you have custom posters, etc, the best way is to put these with your media and not just keep them in the database. PMS will recognize local posters (poster.jpg) and use whatever you supply.

I’m not too concerned about watched status as I can get that back from trakt.tv

I’m much more concerned about custom tags and edits to metadata I did. It would be very painful if not impossible to re-do all of this.

I’m pretty sure that the offending library is ‘Audiobooks’ as this is the last change I made - adding the data scaper Audiobooks and running it. Is there a way of deleting just this library and all related info but keeping all my other 16 libraries?

By the way, I did have a backup path set-up for the library but it looks like the server never created one. The folder doesn’t even exit and there are no warnings / error messages regarding backups. Not a very reliable feature I have to say…

With server versions above 1.13.1, you need to perform 2 additional commands before all others in the repair procedure.
These will remove the problematic collation and instruct Plex server to recreate it during the first restart after the repair.

Shut down Plex Server before doing any of the below:

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'"

Now continue with the rest of the procedure as written down in the article.
https://support.plex.tv/articles/201100678-repair-a-corrupt-database/

Unfortunately, these additional steps don’t work. The first creates an error “Error: no such index: index_title_sort_naturalsort”, and the second one “Error: no such table: schema_migrations”…

I am really devastated now having to re-create the whole library I fed and built over years and am desperate for any help I can get to fix this please.

Is there any way to salvage my (music) playlists? Like retrieve them from the old database and import them into the new one? Or at least export them to see the items so I can re-create them if necessary?

Try WebTools

How can I use WebTools which relies on a running Plex server if the Plex server doesn’t start with the corrupt database? Or can WebTools access the database without a Plex server running?

My apologies! I wasn’t paying attention to the previous posts.

If you are OK with it, zip up your DB file and PM it to me (or put it onto e.g. GDrive and PM me the download link. I can relay it to one of the experts.)

Great, will do tonight when I get back home. Thanks for the offer to help by looking at the database file directly.

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