Metadata & Search Issues

Server Version#: 7.0.0 2025-01-09
Player Version#: 4.145.1
<If providing server logs please do NOT turn on verbose logging, only debug logging should be enabled>

Hello,

I’m new to the Plex Forums, so apologies in advance if there’s anything wrong with this post.

I have been running Plex on my unraid server for about 2 years now, and it was working perfectly. Then a power outrage happened, and I think it caused an issue with my Plex server. I will try my best to describe the issue and provide logs, as it’s really annoying to search and navigate Plex right now.

So, the main issue is that the search bar does not list anything from my server. It simply does not work. When I check the logs, I can see the two errors:

Feb 11, 2025 14:05:39.978 [23169482230584] Error — [Req#b577c] SQLITE3:0x80000001, 267, statement aborts at 16: [select distinct(tags.id) from metadata_items join taggings on taggings.metadata_item_id=metadata_items.id join tags on tags.id=taggings.tag_id join fts4_tag_titles_icu on fts4_tag_titles_icu.rowid=tags.id where fts4_tag_titles_icu.tag match 'sno*' and tag_type=6 and metadata_items.library_section_id in (4) and metadata_items.metadata_type=2 group by tags.id order by count(*) desc limit 100] database disk image is malformed

And:

Feb 11, 2025 14:05:39.979 [23169482230584] Error — Got exception from request handler: sqlite3_statement_backend::loadRS: database disk image is malformed

Clear Filters and Jump to Context

The two major issues I’m facing due to those errors:

1- When I search Plex, it does not show anything related to my server. And yes, I enabled my server as an option for the search.

2- The metadata, cast, ratings, and the poster of the movie/TV show is not clear.

I did Plex DBRepair Script multiple times, but it’s simply not working for some reason. I believe even the backup data is corrupted.

Any help/support is welcomed, I really need to fix this.

Thank you

Please help @ChuckPa! :persevere:

Thank you for your reply. I have tried the DBRepair, but it did not fix the issues stated in the post. I would like to know if there’s a solution or maybe troubleshoot it further.

Frankly, as long as it says “disk image malformed”, there is no point in trying to debug anything else. The DB is where the search index is stored.

Restore one of the database backups, then try to repair that.
https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/

If that does fail as well, then your db might be damaged beyond repair.

What if the backup version itself is corrupted? I’m willing to nuke my database if it actually solves the issue.

malformed=corrupted

How did you perform your first attempt at repairing the DB?
Was it also by using the above linked script?

Sorry, I meant the backup is also corrupted, not only the database.

I followed the guide and made sure everything is done correctly. This is why I tagged @ChuckPa. Last time I tried was last month, when they have updated the Github page.

Well, the “nuclear option” is to

  1. stop plex server
  2. empty out the plex data folder completely, but copy the Preferences.xml file someplace else. Do also copy the cert-v2.p12 file from the Cache subfolder.
  3. start Plex server again, let it run for a few minutes
  4. stop plex seerver
  5. copy back the two saved files to their original places
  6. start plex server again and try to access it using the plex web app

Keep in mind that the most common reasons for database damage are:

  • moving the plex data folder to a network file share (never, ever even consider it)
  • cutting power/hard reset the server [virtual] machine, instead of shutting down in an orderly fashion

Think about your own configuration and usage habits. Maybe you can change something to prevent damage in the future.

Thank you so much for your reply, I will attempt to do that.

One last thing, will I lose any data related to the users using my Plex? Do I need to re-invite them again?

If they (and you, too) had enabled the syncing of “watched” data to their accounts on plex.tv, they will not lose that status.

Since the DB is gone, you will have to enter each user in “Manage Library Access” and edit their access permissions. Remove their access to the old libraries and add them to the new ones. A complete re-invitation is not necessary, because you have saved the Preferences.xml, which is holding your server’s “identity” (to which the sharing is bound ultimately).

Here are the steps I did:

DBRepair.sh  DBRepair.sh.bak  Library  databasetools
# ./DBRepair.sh
 
 
 
      Plex Media Server Database Repair Utility (Docker)
                       Version v1.10.02
 

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 5
 
Unable to repair databases.  PMS is running.

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 1
 
Stopping PMS.
Stopped PMS.

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 5
 
Exporting current databases using timestamp: 2025-02-11_14.44.58
Exporting Main DB
Exporting Blobs DB
Successfully exported the main and blobs databases.
Start importing into new databases.
Importing Main DB.
Importing Blobs DB.
Successfully imported databases.
Verifying databases integrity after importing.
Verification complete.  PMS main database is OK.
Verification complete.  PMS blobs database is OK.
Saving current databases with '-BACKUP-2025-02-11_14.44.58'
Making repaired databases active
Repair complete. Please check your library settings and contents for completeness.
Recommend:  Scan Files and Refresh all metadata for each library section.

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 3
 
Checking the PMS databases
Check complete.  PMS main database is OK.
Check complete.  PMS blobs database is OK.

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 9
 
Are you sure you want to restore a previous database backup  (Y/N) ? y
Checking for a usable backup.
Database backups available are:  2025-02-11 2025-02-08 2025-02-05 2025-02-02
 
  1) - 2025-02-11
  2) - 2025-02-08
  3) - 2025-02-05
  4) - 2025-02-02
 
Select backup date by number or date name  (blank = return to menu) 1
Checking backup candidate 2025-02-11
Database backup 2025-02-11 is valid.
 
Use backup dated: '2025-02-11' ? (Y/N) ? y
Saving current databases with timestamp: '-BACKUP-2025-02-11_14.48.49'
Copying backup database from 2025-02-11 to use as new database.
Copy complete. Performing final check
 
Database recovery and verification complete.

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 6
 
Backing up of databases
Backup current databases with '-BACKUP-2025-02-11_14.50.33' timestamp.
Reindexing main database
Reindexing main database successful.
Reindexing blobs database
Reindexing blobs database successful.
Reindex complete.

Select

  1 - 'stop'      - Stop PMS.
  2 - 'automatic' - Check, Repair/Optimize, and Reindex Database in one step.
  3 - 'check'     - Perform integrity check of database.
  4 - 'vacuum'    - Remove empty space from database without optimizing.
  5 - 'repair'    - Repair/Optimize databases.
  6 - 'reindex'   - Rebuild database indexes.
  7 - 'start'     - Start PMS

  8 - 'import'    - Import watch history from another database independent of Plex. (risky).
  9 - 'replace'   - Replace current databases with newest usable backup copy (interactive).
 10 - 'show'      - Show logfile.
 11 - 'status'    - Report status of PMS (run-state and databases).
 12 - 'undo'      - Undo last successful command.

 21 - 'prune'     - Remove old image files (jpeg,jpg,png) from PhotoTranscoder cache & all temp files left by PMS.
 42 - 'ignore'    - Ignore duplicate/constraint errors.

 88 - 'update'    - Check for updates.
 99 - 'quit'      - Quit immediately.  Keep all temporary files.
      'exit'      - Exit with cleanup options.

Enter command # -or- command name (4 char min) : 99
 
Retaining all temporary work files.
#

You first repaired the database, then replaced that repaired one with an unrepaired backup.

First I did the automatic, and nothing happened. Then I followed the guide (mentioned on github) "The repair sequence (3, 9, 6, 99)

What did you expect to happen? Have you tried to start the server after that repair?

I have tried everything, but still did not repair the errors in the logs. I tried repair without replacing, same results. & yes, I restarted after the repair.

[Req#1051d2] SQLITE3:0x80000001, 267, statement aborts at 16: [select distinct(tags.id) from metadata_items join taggings on taggings.metadata_item_id=metadata_items.id join tags on tags.id=taggings.tag_id join fts4_tag_titles_icu on fts4_tag_titles_icu.rowid=tags.id where fts4_tag_titles_icu.tag match 'parasite*' and tag_type=6 and metadata_items.library_section_id in (4) and metadata_items.metadata_type=2 group by tags.id order by count(*) desc limit 100] database disk image is malformed

Got exception from request handler: sqlite3_statement_backend::loadRS: database disk image is malformed

Sorry for the late reply.

Then there is only the nuclear option left, as described above. This means a complete loss of all libraries and metadata (but not the media files themselves).

Thank you so much, will do it over the weekend.

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