DBRepair development

I don’t know why either but suspect there’s something deep in the DB not right

You have backups from before this happened.
-or–
watch history sync’d ?

Backups, yes.

Watch History is synced

Right now, db is repaired. I’ll wait a week and see if the indexes stay “fixed”

Don’t be surprised if you need to roll back pretty far .

I don’t know what FTS index work they’ve done. (recent / past / distant past )

I ran a full repair this morning, DBRepair found “One or more FTS indexes are DAMAGED”, repaired them and when I re-ran 3) ‘check’ - Perform integrity check of database and FTS indexes. no errors.
Just checked and the error is back, so I don’t know how they get damaged again.

Is the storage local on the machine?

Which PMS version?

Version 1.43.0.10492

Storage is on a USB HD
database is local

I’d make a backup of what you have after you repair it.
Then back down to 1.42 and see if it’s 1.43 related

Beyond that, there’s nothing I can do anymore.
You’ll need to reach out to Plex for help.

Thanks for trying.

Since the index is ok after the DBRepair fix, I’m now thinking that the subsequent Scan, Refresh Metadata may be reintroducing the index errors.

That will take someone in Plex Engineering to fix.

@Tony_T @ChuckPa I done some more tests on this today. It appears the tables that are being continually reported as damaged are fts4_metadata_titles, fts4_metadata_titles_icu, fts4_tag_titles and fts4_tag_titles_icu within the main and blogs db.

So I ran …

  1. ran sudo bash DBRepair.sh stop check status start exit - which confirms they are “damaged”
  2. ran sudo bash DBRepair.sh stop automatic status start exit which reindexes and “repairs them”.
  3. ran sudo bash DBRepair.sh stop check status start exit - which confirms they are still reported as okay
  4. ran a manual scan of my libraries
  5. optimise the db
  6. ran sudo bash DBRepair.sh stop check status start exit - to check the indexes again. At this point they are yet again reported as “damaged”.

I’m not sure what this part of the tool is actually trying to accomplish as its looks to be just doing a insert integrity_check …

  # Check each FTS table
  for Table in $FTSTables
  do
    Result="$("$PLEX_SQLITE" $CPPL.db "INSERT INTO $Table($Table) VALUES('integrity-check');" 2>&1)"
    ExitCode=$?

    if [ $ExitCode -eq 0 ] && [ -z "$Result" ]; then
      Output "  FTS index '$Table' - OK"
      WriteLog "$Caller - FTS Check: $Table - PASS"
    else
      Output "  FTS index '$Table' - DAMAGED"
      Output "    Error: $Result"
      WriteLog "$Caller - FTS Check: $Table - FAIL ($Result)"
      FTSFail=1
    fi
  done

… however, at least for me all four of these tables are blank and empty in my db. Maybe they are used in a feature I have disabled!

Anyhow, passing along as information and I’m just going to ignore the reports on these tables as noise and a false positive.

2 Likes

@dokuro , I was just going to do something similar, but though it was the Refreshing of Metadata, not the Scan, and thought it might be related to one Library or maybe one show causing the issues:
FTS index ‘fts4_metadata_titles’ - DAMAGED
FTS index ‘fts4_tag_titles’ - DAMAGED

Tried Metadata Refresh of just one Libray, only error on:
FTS index ‘fts4_tag_titles’ - DAMAGED
Then Refreshed just one show of just one Library and no errors.
So now need to see if I can tail some log files to identify which shoes are causing the damaged indexes

Running a tail -f while refreshing matadota is showing error:
Linux:
tail -f “/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/Plex Media Server.log” | grep -iE “metadata|error|corrupt|fts4|malformed”

@Tony_T

Can you show the log / attach the log zip which captures it?

We’ll see if @FordGuy61 or someone can submit the bug.

That won’t find it.

Even running a …

"/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "PRAGMA integrity_check"

… on the db won’t report anything. Its just the code segement I included above from the dbrepair tool which reports this failure.

Run the check.

ON THE NEXT line, type:

echo $?

This is important. (the status returned from the DB check.
Do not type any other commands after running the check before typing this.

Yeap, its reported as “ok” (as it always is) :slight_smile:

[plex]-[dokuro]:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases]$ pwd
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases
[plex]-[dokuro]:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases]$ sudo service plexmediaserver stop
Redirecting to /bin/systemctl stop plexmediaserver.service
[plex]-[dokuro]:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases]$ sudo "/usr/lib/plexmediaserver/Plex Media Server" --sqlite com.plexapp.plugins.library.db "PRAGMA integrity_check"
ok
[plex]-[dokuro]:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases]$ echo $?
0
[plex]-[dokuro]:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases]$ sudo service plexmediaserver start
Redirecting to /bin/systemctl start plexmediaserver.service
[plex]-[dokuro]:/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases]$ 

I did not ask for the “OK” output.

I’m interested in the echo $? output

There is a difference.

I’m likely going to need a copy of the DB to diagnose this.

Sorry, misunderstood, I updated the comment above. It reports 0.

I’m also sorry but I’m not handing over my db :-(. Maybe @Tony_T would be happy to do that. For myself, happy to run anything you wish but the data in my db is mine and I’m not giving it away, sorry.

@dokuro

I’m not interested in your DB. Tony is reporting the problem.
He and i will make arrangements if he’s so inclined.

@ChuckPa Let me know if you need a second DB to examine. I’ve got a small’ish test server whose main DB is less than 10 MB (the blobs DB is a little less than 40 MB). The problem is reproducible on this server as described above.

If you’d like the files, PM me and I can send you a download link.

@ChuckPa - I Fixed my Database :grinning_face:

EDIT: While no errors yesterday (tested more than a few times), this morning the errors returned

As @ChuckPa has said “This is a PMS issue. I’ve chatted with FordGuy who will take to Plex.” I’ll just have to wait and see if Plex fixes this issue.

Checking FTS (Full-Text Search) indexes

  FTS index 'fts4_metadata_titles_icu' - DAMAGED

    Error: Error: stepping, database disk image is malformed (11)

  FTS index 'fts4_tag_titles_icu' - DAMAGED

    Error: Error: stepping, database disk image is malformed (11)

  FTS index 'fts4_metadata_titles_icu' (blobs) - OK

  FTS index 'fts4_tag_titles_icu' (blobs) - OK

FTS integrity check complete. One or more FTS indexes are DAMAGED.

Use 'reindex' command (option 6) or 'automatic' (option 2) to rebuild.

For ANYONE ELSE trying this:

1) BACKUP your Database
2) This is ONLY described for Linux
3) USE AT YOUR OWN RISK

Here’s what I did

1) STOP PLEX

sudo systemctl stop plexmediaserver

2) Change to database directory

cd “/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases”

3) IF Exists: Delete the WAL/SHM files (Plex will recreate these)

sudo rm -f *.db-wal *.db-shm

4) Drop the FTS tables entirely from both main and blobs

sudo “/usr/lib/plexmediaserver/Plex SQLite” com.plexapp.plugins.library.db “DROP TABLE IF EXISTS fts4_metadata_titles; DROP TABLE IF EXISTS fts4_tag_titles;”
sudo “/usr/lib/plexmediaserver/Plex SQLite” com.plexapp.plugins.library.blobs.db “DROP TABLE IF EXISTS fts4_metadata_titles; DROP TABLE IF EXISTS fts4_tag_titles;”

5) Vacuum (critical step)

sudo “/usr/lib/plexmediaserver/Plex SQLite” com.plexapp.plugins.library.db “VACUUM;”
sudo “/usr/lib/plexmediaserver/Plex SQLite” com.plexapp.plugins.library.blobs.db “VACUUM;”

6) Start Plex & Wait

sudo systemctl start plexmediaserver

Do not run DBRepair yet.
Start Plex and let it realize the tables are gone.
It will begin a background task to recreate them.


7) STOP PLEX

sudo systemctl stop plexmediaserver

8) Run DBRepair

sudo ./DBrepair.sh
(Run: 2 - ‘automatic’)

9) Start Plex

sudo systemctl start plexmediaserver

10) Scan and Refresh All Metadata

And after a Scan and Refresh Metadata I ran DBRepair 3

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.

Checking FTS (Full-Text Search) indexes

FTS index ‘fts4_metadata_titles_icu’ - OK

FTS index ‘fts4_tag_titles_icu’ - OK

FTS index ‘fts4_metadata_titles_icu’ (blobs) - OK

FTS index ‘fts4_tag_titles_icu’ (blobs) - OK

FTS integrity check complete. All FTS indexes OK.

Vacuum was a critical step

Edit: Decided to subsequently do a Prune (21) and decided I might as well do another Automatic (2) and Database still good! :grinning_face:

Enter command # -or- command name (4 char min) : 2

Automatic Check,Repair,Index started.

Checking the PMS databases

Check complete.  PMS main database is OK.

Check complete.  PMS blobs database is OK.

Exporting current databases using timestamp: 2026-03-10_14.20.35

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-2026-03-10_14.20.35'

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.

Backing up of databases

Backup current databases with '-BACKUP-2026-03-10_14.21.48' timestamp.

Reindexing main database

Reindexing main database successful.

Reindexing blobs database

Reindexing blobs database successful.

Reindex complete.

Checking FTS (Full-Text Search) indexes

  FTS index 'fts4_metadata_titles_icu' - OK

  FTS index 'fts4_tag_titles_icu' - OK

  FTS index 'fts4_metadata_titles_icu' (blobs) - OK

  FTS index 'fts4_tag_titles_icu' (blobs) - OK

FTS integrity check complete. All FTS indexes OK.

Automatic Check, Repair/optimize, Index, & FTS check successful.