Plex Media Server gets stuck during library scan and then freezes completely

Server Version#: 1.29.2.6364 (Running on Synology NAS)
Player Version#: 9.10.1.36024

Every time my library automatically scans for media, it gets stuck on a folder and I am unable to cancel the scan or interact with Plex (not able to edit or add or delete items) until I restart the app on Synology.

Example of stuck server:

Attached are logs:
Plex Media Server Logs_2022-11-18_16-30-13.zip (3.2 MB)

Your database is getting hammered and bringing the whole system to a standstill.

When’s the last time the database was optimized ?

Nov 18, 2022 13:34:54.893 [0x7f017ab66b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:34:55.739 [0x7f017a963b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:34:57.117 [0x7f017ab66b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:34:57.963 [0x7f017a963b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:34:58.350 [0x7f017ab66b38] ERROR - Saving activity history aborted with soci exception: sqlite3_statement_backend::loadOne: database is locked
Nov 18, 2022 13:34:59.193 [0x7f017a963b38] ERROR - Thread: Uncaught exception running async task which was spawned by thread 0x7f017d554b38: sqlite3_statement_backend::loadOne: database is locked
Nov 18, 2022 13:34:59.368 [0x7f017ab66b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:35:01.592 [0x7f017ab66b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:35:03.816 [0x7f017ab66b38] WARN - Waited one whole second for a busy database.
Nov 18, 2022 13:35:04.201 [0x7f017cd0db38] DEBUG - BPQ: onConsiderProcessing: Idle (true)
Nov 18, 2022 13:35:04.201 [0x7f017cd0db38] DEBUG - BPQ: [Idle] -> [Processing]

I’m having this same issue and can not remember where to find the log so i can make a new thread in here. FYI I just updated dsm to 7.1 and then to 7.1.1 and did 2 updates to plex , now on 1.29.2.6364.

I should make a file pad for plex so I can remember a year from now how to do the log download to post

My db is optimized once a week as a scheduled task. This issue has been ongoing since at least 1.29.1.6316. Not exactly sure what’s going on. It still happens after I optimize the DB and clean bundles too

How comfortable are you on the command line?

pretty comfortable. What do you want me to run?

Put this in your Plex shared folder on /volume1

  1. SSH into it
  2. elevate to sudo bash (root) privilege
  3. Stop Plex
  4. Untar / unzip
  5. chmod +x DBRepair.sh
  6. ./DBRepair.sh
    – Attempt repair (which is really doing a Full sweep optimize) of the DB.
  7. When done. you can sit in the tool/ssh session and restart Plex to confirm it’s helped.
  8. When done, exit and delete working temp files.

I have example sessions in the Readme.

1 Like

So I did a check, repair and then reindex. Here is the log from the util:

==================================================================================
2022-11-21 14.36.42 - ============================================================
2022-11-21 14.36.42 - Session start: Host is Synology (DSM 7)
2022-11-21 14.38.23 - Check   - Check com.plexapp.plugins.library.db - PASS
2022-11-21 14.41.23 - Check   - Check com.plexapp.plugins.library.blobs.db - PASS
2022-11-21 14.41.23 - Check   - PASS
2022-11-21 14.45.17 - Repair  - Export databases - PASS
2022-11-21 14.46.19 - Repair  - Import - PASS
2022-11-21 14.46.25 - Repair  - Verify main database - PASS (Size: 196MB/178MB).
2022-11-21 14.46.26 - Repair  - Verify blobs database - PASS (Size: 750MB/757MB).
2022-11-21 14.46.26 - Repair  - Move files - PASS
2022-11-21 14.46.26 - Repair  - PASS
2022-11-21 15.13.45 - Reindex - MakeBackup com.plexapp.plugins.library.db - PASS
2022-11-21 15.13.45 - Reindex - MakeBackup com.plexapp.plugins.library.blobs.db - PASS
2022-11-21 15.13.45 - Reindex - MakeBackup - PASS
2022-11-21 15.13.58 - Reindex - Reindex: com.plexapp.plugins.library.db - PASS
2022-11-21 15.14.00 - Reindex - Reindex: com.plexapp.plugins.library.blobs.db - PASS
2022-11-21 15.14.00 - Reindex - PASS
==================================================================================

But the issue is still happening here, on any library scan as you can see here:

I’ve attached the latest logs as well here:
Plex Media Server Logs_2022-11-21_16-01-45.zip (3.8 MB)

SLOW QUERY when scanning isn’t much of a surprise on Synology.

What you see in the console is ERROR only. Your logs show how much actual activity is occurring between those messages

It looks like you’re ingesting media in /volume1/Movies. Is that correct ?

Synology can basically do one thing at a time. Play media or ingest media.
In your logs, both are present at the same time.

a dedicated ssd read (or r/w) cache would improve this behavior. (segmenting the 2 would be better). this is an i/o bottleneck. check cache hit rate in dsm.

note also that the naming schema is off for some items leading to errors in the matcher (which is also compounded by “corrupted media”): “ug 29, 2021 08:54:06.955 [0x7f1e82a31b38] WARN - [FFMPEG] - Format avi detected only with low score of 1, misdetection possible!
Aug 29, 2021 08:54:06.955 [0x7f1e82a31b38] ERROR”

This results in a cycle of attempting to reanalyze the media per cycle with no caching possible. If I/o wasn’t the bottleneck this wouldn’t matter, but since it likely is then the hang rate of those processes slow down other threads.

Yes, my movie folder is /volume1/Movies, however I’m not playing anything at the time this is happening.

This issue usually happens when Radarr or Sonarr is downloading media and it is being imported into Plex at the same time. Or after it has downloaded a bunch of movies (>10 movies) and gets stuck on importing metadata as in the screenshot

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