Recurring database corruption on Ubuntu Server

Server Version#:1.25.0.5246
Player Version#: Web

I am running Plex media server on Ubuntu server 20.04 and the database keeps getting issues. I have tried to recover the database using the a Plex SQLite tool and tried to take a SQL dump off the database and recreating it, but these fixes don’t seem to correct the problem. The only way the works is to recover from an older backup, generally 3 to 4 days old. This is happening weekly now and I can see data disappearing from Plex on the client side as entire sections on the home page so showing up. Eventually Plex stops working and I have to recover the database from a backup.

I have not updated the database to user the new Plex agent yet.

Does anyone have any suggestion on what could be causing this?

Not a dev, but I my gut says you have several degrees of database corruption. (Full crash, and your “working” setup) I bet you do not have a fully clean database, and at some point when plex its doing its scheduled tasks it continues to hit that corruption and “breaks”. Its probably way too late to get a copy of the database from 7-10 days before you first noticed this. Worst case you may need to start over with a clean database.

I’d concur with layers of corruption. This doc might be of help Move Viewstate/Ratings from One Install to Another | Plex Support

If what you describe happened to me I’d do the following…

Export your current view status from the your current db. Once done start again with a fresh plex db and install. Add your libraries exactly the same as you currently have and once complete then import the export you took earlier from above. You’ll have need to check for matches etc…

That should at least keep your view status. Your CW will need to rebuild from scratch but that will happen over time as you watch stuff.

Thanks for the suggestions, however I would like to add some more info that may be relevant:

  1. I have several backups of the plex database, going back to 10/15/2021 for Windows and as far back as 11/19/2021 on Ubuntu
  2. I moved my Plex server from a Win 10 machine to Ubuntu around 10/28/2021
  3. This issue seems to have started when I switched the default user for the plexmediaserver

I can import the database from the windows backup or simply re-install plex and import the veiwstate/ratings as mentioned, but how do know that will fix the problem? I have tried re-creating the database using the SQL .dump and then .read which should have fixed data corruption issues with the file, but are there other ways to fix the database issues?

Can you expand on point 3?

Plex on Linux runs under username “plex” by default, but I was having some issues with that, specifically being able to write to a NAS. To resolve this I changed the default user to for the plex. The method to change the default user for Plex in Linux is shown in the following link:

https://dausruddin.com/how-to-change-plex-user-running-under-in-ubuntu/

Confirm that the DB is on local storage?

@aliakhter

That procedure is out of date.

“PLEX_MEDIA_SERVER_USER” has not been used since Ubuntu 16 was introduced.

It is only valid for SYS V Linux systems (pid 1 = init)

May I suggest reviewing:

Paying attention to:

As @pl_5309 asks – Confirm the Plex metadata and database (PLEX_MEDIA_APPLICATION_SUPPORT_DIR) is on local storage ?

Yes, the database is on local storage.

I commented out the “PLEX_MEDIA_SERVER_USER” change, the rest looks ok. I was only using the override for the user, nothing else like PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, therefore the database is in the default location.

I updated Plex and that seems to have solved the problem. I did have to recover the DB from a backup once, but since then I have not had any issues for about 10. I did change a few settings, I was having issues with Plex automatically scanning daily, so I switched to manually triggering scans. I also upgraded my libraries to the new agent. If I see any more issues I will remove/re-install Plex and recover from my old windows backup. I will try to update this post if that happens.

I am pretty sure this had something to with the Plex DB having an issue with the old metadata agent. Since I upgraded my libraries to the new Plex agent it had been running flawlessly. I tested this theory by manually linking an item to its IMDB page and the DB got corrupted halting PMS within 30 mins. I restored the DB from backup and it has run flawlessly since then.

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