Database Corruption Help

I was not able to update past Version 1.40.2.8395 due to database corruption. I ran the ChuckPa tool and that repaired it enough to do the update.

However, I am no longer able to import new content. According to the scan logs the “database image is malformed”

Is there anything I can do to rectify this? Preferably a repair of my existing database. I have backups dating back to pre ChuckPa repair if needed.

If I need to start with a clean DB what parts can I save/backup and how would I do that?

Thanks

Chiming in because I saw your post on the github and I have the exact same issue.

Description: I’ve done all the manual repair, backup restore, auto repair, manual repair with vacuum and index… nothing, whenever I do a search the logs show me the error with “database image is malformed” and new files don’t get picked up by the agents.

I have managed to get it to add more content by changing the scanner and agent to legacy and then back to the new one, that’s the only way it works, and only for TV not for movies.

@ChuckPa had asked to be pinged in the github message, so I am doing so.

@humbird

May I see the server debug log files ZIP please so I can read what it’s doing/not doing? (the sequence)

Sure thing. I just have the script file in by resources folder (Linux installation) but I don’t see any log files (text, zip, or otherwise) even with a 99 exit. Where would it be storing the logs?

@humbird Chuck is asking for the server log files. settings → troubleshooting.

@FordGuy61 I’m pretty sure @ChuckPa meant the script logs not the plex server logs, but I may be mistaken

“server debug log files ZIP”

FYI, the DB Repair log, DBRepair.log, is in the same folder as the database files.
Plex Data Folder → Plug-in Support → Databases

@FordGuy61 lol server it is! Thanks for catching that and for pointing me to the script logs too. I’ll upload both when I get home.

Okay, here are all the logs @ChuckPa

edit removed after

Thank you for the logs.

I don’t have the best of news for you.

Your DBRepair logs show me the SQL database structure finally iterated into sanity.

The PMS logs show me corruption of the data in those records.

Aug 14, 2024 20:07:30.090 [136368335289144] DEBUG - [Album] Creating album 'Under the Influence with Terry O'Reilly' for artist 'Apostrophe Podcast Network'
Aug 14, 2024 20:07:30.095 [136368335289144] ERROR - [Album] SQLITE3:0x80000001, 267, statement aborts at 182: [update metadata_items set guid=?,hash=? where id=?] database disk image is malformed
Aug 14, 2024 20:07:30.095 [136368335289144] ERROR - [Album] Exception inside transaction (inside=1) (/home/runner/actions-runner/_work/plex-media-server/plex-media-server/Library/MetadataItem.cpp:1139): sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 14, 2024 20:07:30.096 [136368335289144] ERROR - Exception inside transaction (inside=1) (/home/runner/actions-runner/_work/plex-media-server/plex-media-server/Library/MetadataItem.cpp:3847): sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 14, 2024 20:07:30.096 [136368335289144] ERROR - Exception assimilating media item in Under the Influence with Terry O'Reilly: sqlite3_statement_backend::loadOne: database disk image is malformed
Aug 14, 2024 20:07:30.096 [136368335289144] DEBUG - Looking for path match for [/mnt/treunas/podcasts/Under the Influence with Terry O'Reilly/aad371140a09579c2c13698a870740ac.mp3]

The choice is yours:

  1. Delete and recreate the “Podcasts” library section, hoping for the best
    -or-
  2. KEEP this database (for it’s watch history)
  3. wipe everything, including the bad backups, out and start fresh.
  4. reload the watch history from the saved DB

Which do you feel is the easiest ?

Oh that’s good to know. I thought I may have to start from scratch, but deleting the Podcasts one is absolutely not an issue. Hopefully this also fixes my problem with new scans I’ve had lately! I’ll keep you updated.

Is it as simple as removing that library?

Okay, I just deleted my music library altogether. Scans still don’t work, exact searches now return results, but I still get errors for keyword searches along with “unknown metadata type: folder” and the only way to update folders / scan new content is still to revert to the legacy agents.

edit okay this is interesting. When I delete my music library it just re-appears after a few seconds.

image

Is disk image malformed related to the DB or the actual disk?

Alright, I caught the deletion failure in action

This seems to line up with what I’ve seen in other threads where people have issues with properly configured media is not getting added, but they can’t save changes to the library if they try to edit it.

Also I have checked and I have 1TB free on my SSD, and 150GB free on my linux partition on that 2TB SSD so that’s not the issue either.

These are almost always cases where the database is corrupt.
“malformed” can be one of two things:

  1. The database files where records are damaged (not proper SQL records)
    These are the type which my program can fix to a certain level.
  2. The database files where the records are intact but the data in them is garbage / incorrect. My tool cannot resolve these because it doesn’t know how to interpret all the data stored there. That’s what PMS does.

Regarding the errors:

  1. That’s a bad DB record. The contents of the record are junk / damaged.

  2. This is full SQLite DB file damage. My tool can usually fix these.

  3. Metadata : Folder – IGNORE it. Engineering never handled it.

  4. PMS is shutting down. Ignore it.

Interesting. So 1 is probably not fixable by your tool but 2 is? In which case erasing everything is the only fix? Or can I find those records full of garbage and just delete them somehow?

There are some times when fixing the DB allows you to also discard the bad content in the DB… such that you can delete the library section.

Doesn’t look like that’s the case for me this time around so I’m trying to find a way to save my customizations now. This is where having NFO files would be helpful.

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