Problems with database size on Unraid Docker Official

Server Version#: Unraid Docker, latest official, Plex-Media-Server
Player Version#: N/A

My database com.plexapp.plugins.library.db is 138 GB. Keeps growing. I am trying to run the DBRepair tool, but my directories have an odd name, like:
/config/Library/‘Application Support’/‘Plex Media Server’/‘Plug-in Support’/Databases

The tool won’t work with it named like this. Can anyone assist?

The quotes (as shown in the directory listing) are not real.
They are only shown for your edification.

Example:

chuck@ds418:/volume1/PlexMediaServer/AppData$ ls -l
total 12
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    0 Sep  9 20:51 'Bitte legen Sie hier keine Mediendateien ab.'
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    0 Sep  9 20:51 'Please do not place any media files here.'
drwxrwxrwx+ 13 PlexMediaServer PlexMediaServer 4096 Nov 11 00:00 'Plex Media Server'
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    4 Nov 11 00:00  plexmediaserver.pid
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    0 Sep  9 20:51 'Por favor, no coloque ningún archivo multimedia aquí.'
drwxrwxrwx+  3 PlexMediaServer PlexMediaServer 4096 Nov 11 02:00  tmp
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    0 Sep  9 20:51 'Veuillez ne placer aucun fichier multimédia ici.'
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    0 Sep  9 20:51  ここにメディアファイルを置かないでください。
-rwxrwxrwx+  1 PlexMediaServer PlexMediaServer    0 Sep  9 20:51  请不要在此处放置任何媒体文件。
chuck@ds418:/volume1/PlexMediaServer/AppData$

There are spaces in the names. The quotes are there to show you the boundaries of the name. It’s a feature of ls

If you’re trying to specify the path from outside the container or using manual configuration

"/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases"

Thanks. I checked the path because I kept getting this error:
Unable to run automatic sequence. Insufficient free space available on /config/Library/Application Support
Space needed = 443325 MB, Space available = MB

I wondered if it was because of the name.

If it’s saying insufficient free space there’s a problem.

From your output, it looks like you found a bug… Which is disturbing because nobody’s encountered it (not reporting the free space available)

How much space is available?

The script calculates a 3x need for safety margins (converting binary DB → ASCII DB)

I used this command
df -h /config/Library/Application\ Support

Filesystem Size Used Avail Use% Mounted on
shfs 1.4T 853G 430G 67% /config

If it says it needs 443.325 GB
and you have 430 GB available,

It’s correctly saying No.

If you go into the script and run Prune , does it clear out any junk files?

Okay, that seems like it did it. Starting automatic check and repair. Odd that it reported blank for the available size. Part of me feels stupid, but on the other hand, I would have figured it out immediately if it hadn’t reported blank.

Your help is much appreciated. The thing is, I nuked Plex a couple of months ago and started indexing existing libraries. It grew this size quick.

If it’s growing quickly,

Perhaps you should consider turning off some of the default options in your libraries which take up a lot of space ?

Chapter Thumbnails and Index Thumbs are big items.

Look through the “Advanced” Tab (each section) and see what you can turn off BEFORE you nuke it.

You might be able to have PMS delete some of its extra stuff internally first and gain back the space.

I will look at the code to see what I can do for the Space Available calculation when it’s inside a container.

I checked, and Chapter thumbnails were turned off. I will check other options after the repiar tool has finished (as Plex is stopped during the operation), unless you recommend differently.

BTW, Plex often just stopped reponding and the logs said often:
Sqlite3: Sleeping for 200ms to retry busy DB.

I am guessing it was because of the bloat.

Yes. Can you show me a ls -la of the Databases directory?

It’s hard to imagine the DB itself is 100+GB

total 282033828
drwxr-xr-x 1 nobody users         1456 Nov 11 19:34 ./
drwxr-xr-x 1 nobody users          100 Sep 22 12:24 ../
-rw-r--r-- 1 root   root          1947 Nov 11 21:08 DBRepair.log
-rw-rw-r-- 1 nobody users     54303744 Nov 11 18:16 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 nobody users     41324544 Oct 11 04:12 com.plexapp.plugins.library.blobs.db-2024-10-11
-rw-r--r-- 1 nobody users     41523200 Oct 14 07:38 com.plexapp.plugins.library.blobs.db-2024-10-14
-rw-r--r-- 1 nobody users     48152576 Oct 26 14:46 com.plexapp.plugins.library.blobs.db-2024-10-26
-rw-r--r-- 1 nobody users     48690176 Nov  4 16:06 com.plexapp.plugins.library.blobs.db-2024-11-04
-rw-rw-r-- 1 nobody users 147720848384 Nov 11 18:19 com.plexapp.plugins.library.db
-rw-r--r-- 1 nobody users  31271527424 Oct 11 04:12 com.plexapp.plugins.library.db-2024-10-11
-rw-r--r-- 1 nobody users  53924210688 Oct 14 07:37 com.plexapp.plugins.library.db-2024-10-14
-rw-r--r-- 1 nobody users  55504900096 Oct 29 11:54 com.plexapp.plugins.library.db-2024-10-29-tmp
-rw-r--r-- 1 nobody users         1024 Oct 29 09:04 com.plexapp.plugins.library.db-2024-10-29-tmp-journal
-rw-rw-r-- 1 nobody users        32768 Nov 11 19:26 com.plexapp.plugins.library.db-shm
-rw-rw-r-- 1 nobody users            0 Nov 11 18:19 com.plexapp.plugins.library.db-wal
drwxr-xr-x 1 root   root             0 Nov 11 18:16 dbtmp/
-rw-rw-r-- 1 nobody users    145944576 Nov 11 18:11 tv.plex.providers.epg.cloud-c6a2292e-6d0f-41f7-9fbe-db3ac09d1748.db
-rw-rw-r-- 1 nobody users        32768 Nov 11 18:18 tv.plex.providers.epg.cloud-c6a2292e-6d0f-41f7-9fbe-db3ac09d1748.db-shm
-rw-rw-r-- 1 nobody users      1120344 Nov 11 18:16 tv.plex.providers.epg.cloud-c6a2292e-6d0f-41f7-9fbe-db3ac09d1748.db-wal

That is huge bloat (5x).

Did you recently add a lot of media ??

I probably have around 13,000 TV episodes (31 TB) and 1,000 movies (11 TB). Its big, but I would imagne that many people have more.

I have started adding media more frequently…forgot to answer that question. As I mentioned before, I also started from scratch and added a ton of media all at once as they were already present in directories that I added as libraries.

Ok… that’s what I was expecting.

How about this? (as root of course)

  1. Stop Plex (of course)
  2. Move com.plexapp.plugins.library.db and com.plexapp.plugins.library.blobs.db to another drive / somewhere with enough space.
  3. cp com.plexapp.plugins.library.db-2024-10-11 com.plexapp.plugins.library.db
  4. cp com.plexapp.plugins.library.blobs.db-2024-10-11 com.plexapp.plugins.library.blobs.db
  5. rm *-shm *-wal (clears out pending transactions which hose the DB)
  6. rm -rf dbtmp (get rid of it for now)

With the bloated DBs out of the way,

  1. Run the tool
  2. When done, scan files to have it pick up all the changes since last backup

If you’re successful here, and don’t get bloat, you can discard that bloated DB set

I have about double what you do and my DBs are less than 1GB

[chuck@lizum Databases.2010]$ ll -h
total 4.0G
drwxr-xr-x 2 chuck chuck 4.0K Nov  8 18:18 ./
drwxr-xr-x 7 chuck chuck   96 May  7  2024 ../
-rw-r--r-- 1 chuck chuck 886K Oct  5 19:08 blobs.sql
-rw-rw-r-- 1 chuck chuck 1.5M Nov  7 14:24 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 chuck chuck 1.5M Oct 23 13:00 com.plexapp.plugins.library.blobs.db-2024-10-23
-rw-r--r-- 1 chuck chuck 1.5M Oct 26 13:03 com.plexapp.plugins.library.blobs.db-2024-10-26
-rw-r--r-- 1 chuck chuck 1.5M Oct 29 13:18 com.plexapp.plugins.library.blobs.db-2024-10-29
-rw-r--r-- 1 chuck chuck 1.5M Nov  1 13:00 com.plexapp.plugins.library.blobs.db-2024-11-01
-rw-rw-r-- 1 chuck chuck 624M Nov  8 18:18 com.plexapp.plugins.library.db
-rw-r--r-- 1 chuck chuck    0 Oct  5 18:55 com.plexapp.plugins.library.DB
-rw-r--r-- 1 chuck chuck 757M Oct 23 13:00 com.plexapp.plugins.library.db-2024-10-23
-rw-r--r-- 1 chuck chuck 741M Oct 26 13:03 com.plexapp.plugins.library.db-2024-10-26
-rw-r--r-- 1 chuck chuck 741M Oct 29 13:18 com.plexapp.plugins.library.db-2024-10-29
-rw-r--r-- 1 chuck chuck 652M Nov  1 13:00 com.plexapp.plugins.library.db-2024-11-01
-rw-r--r-- 1 chuck chuck 9.5K Nov  8 13:35 DBRepair.log
-rw-r--r-- 1 chuck chuck 557M Oct  5 18:58 main.sql
[chuck@lizum Databases.2011]$ 

Okay. I did what you said. I am guessing that 30 Gb will take some time. I willl check back tomorrow. Thanks so much. Note that after I started the repair, it recreated -shm and -wal. It seems that they are the same size as what I posted before.

One thing I will want to know is, what can I do in the future to make sure that this doesn’t happen. Do I just add media slowly?

Without knowing exactly what you did, I can’t really describe.

I do the bare minimums for each library type.

I don’t use photos and have minimal audio.

I would add it slowly and consider cleaning it / optimizing it between major blocks.

FYI.

[chuck@lizum media.2015]$ find tv* -name \*.mkv -print | wc -l
10736
[chuck@lizum media.2016]$ find uhd movie* animated -name \*.mkv -print | wc -l
1667
[chuck@lizum media.2017]$ [chuck@lizum media.2019]$ gog df -h /vol
Filesystem      Size  Used Avail Use% Mounted on
/dev/md3        110T   72T   38T  66% /vol
[chuck@lizum media.2018]$ 

I keep the files big (I like the quality)

Thanks. I have a combination of different container types, not just mkv. It finished after a few hours, and am down to 14 Gb now. Still much larger than yours. I had to change the ownership from root:root to nobody:users.

Any idea on how to reduce the file more? Maybe remove photo libraries? I have a small amount of music, but I can eliminate that as well.

I assume I can delete dbtmp now.

Regarding thumbnails. I see in the settings, there are two options for thumbnails:
Generate chapter thumbnails - Never
Generate video preview thumbnails (is this index thumbnails you were referring to before?) - Never (this might have been enabled before.)

  1. My total Plex metadata (I moved it from /var/lib) is
[chuck@lizum plex.2002]$ sudo du -hs .
23G	.
[chuck@lizum plex.2003]$ 
  1. Video Preview Thumbnails
  • turn them off
  • Hit the button to remove them.

I wanted to provide an update. I ended up removing a large library. During that process the database got corrupted, so I ran DBRepair again. I am down to 370 Mb now. I deleted a lot of the old files from that directory and then am moving those files to an existing library. Still good. After each batch I optimize. Still close to 370 Mb.

Thanks for all of the help!