Instant DB corruption

Server Version#:4.159.0
Player Version#:
<If providing server logs please do NOT turn on verbose logging, only debug logging should be enabled>

I noticed historically added shows/seasons started disapering so i backed up the db and restored an older version. No luck. Same shows missing.

Tried to fix DB eith repair script: https://github.com/ChuckPa/DBRepair

Main DB Ok.

Blobs Db Ok.

FTS DB Corrupted.

Tried the most aggresive opions. Still no luck.

Tried removing all libary root directory so plex deletes all shows/movies. Still no luck

I tried a complete reinstall of plex, and manually re-adding all libary folders. Exactly Same shows missing. FTS DB corrupted again.

This might be caued by several issues. Most likley the use of the apostraphy in filenames/metadata eg:

$string1 = ‘Pan’s labrynth’

I dont think using double quotes is a sane soluion because " treats the string as code instead of text. This might open up shellcode injection. eg:

$string2 = “Pan’s labrynth $(insert shellcode)”

cant show example using backtick due to bbcode

The only solution im aware of is url encoding asap, or at the very least just before it hits the DB. Also the last step before the string is displayed

https://en.wikipedia.org/wiki/Percent-encoding

this will encode it like:

Pan%27s%20labrynth

Recoding plex to use url encoding will break plex pretty hard and a lot of work to fix. Dont expect admins to fix this any time soon. While this issue wont break everything using a ’ it willl eventually rot away at the DB untill it eventually corrupts. Its more a volumetric issue.

The other issue is Plex does not play nice with sshfs path/mount when adding libary directories. Instead of Plex transpently traversing the mountpoint it duplicates the mounpoint and does not open/traverse past mount point eg

/home/user/done/ ← sshfs mount point

/data/home/user/done ← unknown duplicate

Sub-folders can be added manually by typing the sub-dir path

Plex DB’s are 99÷ scraped from the net. Having an option to do Nucklear option under troubleshooting options is to:

A: Backup the DB

B: Export friends list/tags/root libary folders, into a human readable format text file.

C: Create new DB and reimport the text file when selected, Then repopulate the db with online media sources.

I think Plex backes up and bindes to the account holder but 90÷ of my friends are missing and the even this appears to have been corrupted. (plz take a look when u have time) oerhaps an a-zo-9 filter to prevent corruption in external friends bound to plex account.

ty for the help

Edit: Thinking about it you could as a tempoary bandaid solution filter out ’ and ` and $ or all invalid charecters but some shows/movies rarley use invalid charecters as in their name. This will be vastly simpler to implement.

Edit2: added screenshots

sry for the double post. The only way i can think of thats corrupting the DB is that ‘Application Data’ folder is a simlink to another partition.

i need to rebuild the DB anyway so i can reinstall. So I can turn on debug logging and add the libary root folders then upload a copy of the corrupted databases. That way the plex devs/mods can backtrace and see exactly where and how the db is corrupting. I need to know where to send the links via a pm. (The DB is far larger than expected being about 850 megs for main db and 250 megs for blob db) Admitedly this issue is stretching the limits of my knoledge. I could use the feature preview nfo files and upload the sub directories nfo where the missing directorys are gone due to corruption in the libary.

Why are you symlinking? What operating system hosts your Plex Media Server? Systems based on systemd provide a native means of relocating the PMS data directory.

Does your symlink point to an external drive or a network share?

the db and transcoder are on the hosts system partition. i think its on the same physical drive. The main reason is if i accidently run out of space it dosent corrupt the db as new files are added. the hosts admins allready had a simlink as their default standad image for all users i just redirected it to the root dir /plex/… along side /var /etc /home ecetra honestly i dont know systemd that well if having a choice id be running alpine instead of ubuntu

Is this not your server?

At any rate, there’s no need to symlink. You can change the default PMS service defaults for such things using an override file. This FAQ question describes it in more detail:

There is one thing I’d suggest though. Instead of manually creating the directory/file as described in the link, just use sudo systemctl edit plexmediaserver to create/edit the override file.

I’d double-check the location of your linked PMS data directory. It cannot reliably be stored on network storage. If it is, you can expect database corruption.

I reported this a while ago in this thread DBRepair development - #920 by dokuro. There is lots of detail in that thread so I suggest you take a look. To summarise, the tool will ALWAYS report the FTS indexes as corrupt after a scan of a library it done.

I personally see this as a false positive and moreover I reverted the DBRepair tool to version v1.13.02 which does not do this fts check.

Indeed, it always appears to be corrupted after a scan. I think it’s because of how PMS rebuilds the indexes (or doesn’t) itself after scans. It seems to do it lazily, not in realtime. It’s unfortunate as it leads to these kinds of misunderstandings.

The net result is that the full-text search functionality may not have the most up-to-date information. But the database is not corrupted in any way even if reported as such (for the FTS tables).

Exactly and that is the key point which is why I call it a false positive. There is really nothing wrong.

I completely agree.

But I mostly wanted to convey to the OP that there’s a better way to relocate the PMS data directory. And to reinforce the precept that it shouldn’t be located on external storage.

Thank you for the help. Sory for the misunderstandings and the late reply. I was melting my brain with all the systemd man pages. Then fixing a significant pile of walls of complexity and issues. The duplicate home directories arent caused by sshfs/plex it was a simlink that i didnt notice. So that can be ruled out. I dont own the local network or the server hardware which makes workarounds iritating. Im actualy running 2servers (i needed the space) one as primary, the other as luke warm storage.

i did deflate and prune, it might be posible that db repair knocks out the friends list