Plex server unresposnive for extend amounts of time during the DB optimization

Server Version#: Version 1.42.0.9975

A Linux box (LXC container), Ubuntu 22.04.5, ZFS mirror SSDs for local storage (non-media stuff).

Started about a month or so ago, after the weekly optimization task is kicked off during the night, the server becomes unresponsive for… well, basically indefinitely (specifically, the web UI). I would usually just restart it after 4+ hours.

In the background, the Plex service is OK, it consumes 100% of a single core of my CPU (Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz) - probably the single-threaded SQLite process

I/O will start “strong” - about 90M read / 50M write, but will start falling away, to a ~5M/2M after about 40 minutes.

Throughout the entire time, one core would remain continuously maxed out.

I’ve noticed in the last run that com.plexapp.plugins.library.db-wal would reach ~30GB, but the size wouldn’t change after several minutes, and the file sizes of all DB-related files would remain the same.

What would eventually happen is that I would restart the plexmediaserver service, and everything would return to normal until the next run.

I’ve found this topic: ERROR: Database Locked while scanning TV Shows - #4 by ChristianKent that mentions an issue with the DB bloat and a fix for Windows servers, but not for Linux boxes.

I have somewhat of a bigger library (~270 TV shows, ~2000 movies), but it has been growing at a normal pace; there was no sudden ingestion of a huge amount of files to explain this degrading performance of the DB optimization process.

Here are the DB-related file sizes:

-rwxrwx--- 1 plex plex 5.1M Aug 20  2022 com.plexapp.dlna.db
-rwxrwx--- 1 plex plex  32K Aug 20  2022 com.plexapp.dlna.db-shm
-rwxrwx--- 1 plex plex 5.2M Aug 20  2022 com.plexapp.dlna.db-wal
-rwxrwx--- 1 plex plex 650M Jul 16 06:04 com.plexapp.plugins.library.blobs.db
-rwxrwx--- 1 plex plex  32K Jul 17 10:27 com.plexapp.plugins.library.blobs.db-shm
-rwxrwx--- 1 plex plex  11K Jul 16 06:04 com.plexapp.plugins.library.blobs.db-wal
-rwxrwx--- 1 plex plex  44G Jul 17 09:11 com.plexapp.plugins.library.db
-rwxrwx--- 1 plex plex    0 May 17  2023 com.plexapp.plugins.library.db-2023-05-17-tmp
-rwxrwx--- 1 plex plex 110M Jul 17 10:48 com.plexapp.plugins.library.db-shm
-rwxrwx--- 1 plex plex  33G Jul 17 10:48 com.plexapp.plugins.library.db-wal

Did anyone face this issue and fix it for themselves?

Once you have removed the bloat, optimize the Plex DB file and align the block size of the DB with the ZFS record size of your ZFS volume. (if you have put the plex data folder on the ZFS volume, that is)

That is Plex Media Server de-bloating the database. It can take several hours. Plex will be unresponsive during the de-bloating.

An alternative is deflate.sh mentioned in the thread @ChristianKent linked. It is faster than letting PMS perform the de-bloating.

Here’s the Linux version: Library.db size more than doubled in latest version - #375 by ChuckPa

1 Like

Awesome, thank you everyone for the help, that script fixed it: Library.db size more than doubled in latest version - #357 by ChuckPa.

From ~40GB to ~300MB.

Also, thanks for the DB alligning tip.

1 Like

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