ERROR - SQLITE3:0x10, 11, database corruption at line 79221 of [fc49f556e4]

Trying to fix this issue
ERROR - SQLITE3:0x10, 11, database corruption at line 79221 of [fc49f556e4]
I used
https://support.plex.tv/articles/201100678-repair-a-corrupt-database/

I get to this part
sqlite3 com.plexapp.plugins.library.db < dump.sql
and I get
Error: near line 982: UNIQUE constraint failed: media_parts.id
Error: near line 383308: no such collation sequence: naturalsort

Might need help from a database person for this one…

Linux Ubuntu 16.04
PMS: 1.13.4.5271

The support article is being updated.

Here’s the interim steps from the team (sa2000) about how to clear the offending index so you can recover

new error after following instructions

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’"
sqlite3 com.plexapp.plugins.library.db .dump > dump.sql
mv com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original
sqlite3 com.plexapp.plugins.library.db < dump.sql

Error: near line 981: UNIQUE constraint failed: media_parts.id

and if I check the integrity of the DB I get this

/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases# sqlite3 com.plexapp.plugins.library.db "PRAGMA integrity_check"

*** in database main ***
On tree page 771 cell 1: Rowid 5865 out of order
Fragmentation of 1 bytes reported as 0 on page 769
On tree page 808 cell 6: Rowid 1761 out of order
row 863 missing from index index_media_parts_on_size
row 863 missing from index index_media_parts_on_deleted_at
row 863 missing from index index_media_parts_on_file
row 863 missing from index index_media_parts_on_hash
row 863 missing from index index_media_parts_on_media_item_id
row 863 missing from index index_media_parts_on_directory_id
row 864 missing from index index_media_parts_on_file
row 864 missing from index index_media_parts_on_hash
database disk image is malformed

To confirm so I can go to Engineering:

  1. You DROPped the naturalsort constraint
  2. Ran the integrity check above
  3. Found the root damage/corruption in the DB.

yep, and I did it twice just to confirm - same results both times

This is still an issue, plex sort of works, but fails all the time. Folders don’t load, files won’t play. Lots of fun…

Could I get some help?

That error means that the unique id has been used twice, which shouldn’t happen normally. You will need to first identify the duplicate, then delete one of them, which should then remove the corruption and things should go back to normal.

First, run

select count(id) from media_parts group by id having count(id) > 1;

That will tell you the id for the duplicate entries. You then need to view these entries:

select * from media_parts where id = 1;

Replace that 1 with the result of the first part. Then after looking at the 2, decide which one you want to delete. Or to make it simple, you can delete both. One of them should get recreated on your next library scan.

bit of a db newb, I ran the commands exactly and nothing (no output)

I take it your supposed to run the command after getting into the database with “sqlite3 com.plexapp.plugins.library.db”

of note, I am fine with loosing a few things here and there, I just don’t want to spend a month rebuilding the whole database

Yup. I wonder if the corrupted data is preventing those commands from running too.

Can you just zip up the file and PM it to me?

Sending you a PM

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