Database backup causes Plex to become unresponsive

Server Version#: 1.28.1.6041
Player Version#: 4.88.1

Whenever a backup is made of the database, Plex becomes unresponsive and Plex Web (and all other clients) can no longer connect to it. In Plex Web, the icon at the top that normally shows the number of streams playing and displays Activity, no longer displays anything (if I click on it, it only shows a smaller version of the dropdown with no information in it). And in the list of available servers, it shows that the server is unavailable or cannot connect.

This started happening fairly recently, and I think it has to do with the size of my database. Still, I think Plex should do a better job of being able to work with a large library, rather than just becoming unresponsive or not accepting connections.

Is there anything I can do about this?

In order to do a backup of the database, the database must be locked for exclusive access by the backup task.

This is unavoidable to get a good backup.

Backups are made during maintenance (Scheduled Tasks).

Is there a time you can change that to which doesn’t conflict with normal playback activity ?

Hey Chuck, thanks for your reply. This seems like something else though. I have the maintenance window happening overnight, and I’ll wake up in the morning and Plex has been unresponsive and unavailable for several hours.

Also, if I trigger a backup manually via the API, sometimes the backup happens without problem, and other times it will go unresponsive for an hour or more.

When the database is locked, I assume that will cause the behavior I was describing? How long should this last, even for a very large database?

@ChuckPa so this morning, I woke up to a notification that Plex had stopped responding at 6:04am. This was almost 2 hours later, and it was still down. So I had to do a restart of the service to get it back up again.

I am including the logs here, I downloaded them after the restart. I don’t know if that is helpful but maybe you can find something helpful in them.

Plex Media Server Logs_2022-08-11_07-57-19.zip (2.7 MB)

Thanks for those logs.
Unfortunately, due to the number of users you have and all the notifications which are flying around in there, the 6:04 am time slot rolled off the backend.

The oldest timestamp is 6:28

So we can get a wider window?

  1. Stop Plex
  2. Edit Preferences.xml in any Linux text editor.
  3. On the last line, before the closing /> , add
LogNumFiles="10"

It will look like this: SomePref="value" LogNumFiles="10" />

Save and restart PMS.

We might need to increase it again but, for now, this will increase the depth from 20 minutes to :crossed_fingers: 40 minutes

Hi Chuck, thanks for this. I’m not in front of my computer but I’ll do this later today.

In the meantime, can you search the logs for a database backup, or do you need a specific time stamp? The reason I ask is, I know I did another attempted backup later in the morning. I’m just not sure if I did it before or after downloading these logs.

Either way, if this doesn’t help you find it, I’ll do another attempt in a little bit and send you the results. Thanks!

I looked for a database backup task but there was too much other activity to capture it.

Your oldest log started at 7:28. (93 user notifications will do that to you LOL)

If you examine the files in the filesystem, how big are they?
How many media items, in total, do you have indexed?

We might need a simple compaction / vacuum operation to clean them up

Hi Chuck, see if this is any better. I did another backup attempt, and after it went non-responsive, I let it sit for a few minutes, then restarted and downloaded the logs immediately. So this should include the backup attempt, which was done at around 2:05.

Also, I have recently done a manual vacuum of the database, in fact as early as a day or two ago. I can do it again, but I don’t think it will make much of a difference.

I don’t want to scare you, but this is a truly massive database. I know some that have larger libraries that don’t have problems, but I know this is one of the larger libraries I’m personally aware of.

# "/usr/lib/plexmediaserver/Plex SQLite" com.plexapp.plugins.library.db "PRAGMA page_count;"
733410
# "/usr/lib/plexmediaserver/Plex SQLite" com.plexapp.plugins.library.db "PRAGMA max_page_count;"
1073741823
# "/usr/lib/plexmediaserver/Plex SQLite" com.plexapp.plugins.library.db "select count() from media_streams;"
2759947
# "/usr/lib/plexmediaserver/Plex SQLite" com.plexapp.plugins.library.db "select count() from media_items;"
725760

Plex Media Server Logs_2022-08-11_14-10-05.zip (4.3 MB)

The number of items isn’t scaring me. You should see my QA test library :slight_smile:

How many files do you have indexed ?

That’s the select count(*) from media_parts;

It should be close to the find /dir1 /dir2 /dir3 -type f -print | wc -l

what does ls -lah "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Databases" look like?

I do see the backup running (which locks the DB).
Are you using the “Backup Database” function of Plex/web which exports the DB and downloads it to you?

Hi Chuck, sorry for the delay, I’ve been running around all day. I’m back now and should be able to reply pretty quickly.

Hopefully this is what you meant about number of files indexed: 725783.

"/usr/lib/plexmediaserver/Plex SQLite" com.plexapp.plugins.library.db "select count(*) from media_parts;" 725783

And here’s a ls -alh of the database directory:

# ls -alh
total 8.6G
drwxr-xr-x 2 plex plex 4.0K Aug 11 08:11 .
drwxr-xr-x 8 plex plex 4.0K Oct 21  2021 ..
-rw-r--r-- 1 plex plex 1.5G Aug 11 11:08 com.plexapp.plugins.library.blobs.db
-rw-r--r-- 1 plex plex  32K Aug 11 14:14 com.plexapp.plugins.library.blobs.db-shm
-rw-r--r-- 1 plex plex 1.5G Aug 11 12:03 com.plexapp.plugins.library.blobs.db-wal
-rw-r--r-- 1 plex plex 2.8G Aug 11 17:52 com.plexapp.plugins.library.db
-rw-r--r-- 1 plex plex    0 Aug  2 12:51 com.plexapp.plugins.library.db-2022-08-02-tmp
-rw-r--r-- 1 plex plex  512 Aug  2 12:51 com.plexapp.plugins.library.db-2022-08-02-tmp-journal
-rw-r--r-- 1 plex plex    0 Aug  5 06:02 com.plexapp.plugins.library.db-2022-08-05-tmp
-rw-r--r-- 1 plex plex    0 Aug  8 06:01 com.plexapp.plugins.library.db-2022-08-08-tmp
-rw-r--r-- 1 plex plex    0 Aug 11 06:02 com.plexapp.plugins.library.db-2022-08-11-tmp
-rw-r--r-- 1 root root 2.9G Aug 11 08:08 com.plexapp.plugins.library.db.bak
-rw-r--r-- 1 plex plex  32K Aug 11 17:53 com.plexapp.plugins.library.db-shm
-rw-r--r-- 1 plex plex  12M Aug 11 17:53 com.plexapp.plugins.library.db-wal

That’s not too bad… :rofl:

Last two questions before I go deep diving.

  1. Where is PMS metadata stored? HDD or NVMe SSD
  2. How long constitutes “becomes unresponsive” (I will be asked)

FYI: Your last log file didn’t have 10 log rollovers in it. It had the default 5. Have you made the change to retain more?

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