Server hangs/crashes on adding new items to library

Server Version#: Version 4.148.0
Player Version#:Any
(Synology DSM 7.01 running on a DS920+)

I’m having a bit of an odd issue. After upgrading, a few versions back, now my server hangs on scanning new library items and becomes stuck on scanning Plex versions. Sometimes this does eventually complete and add my media, however only one item at a time until the server hangs and has to be restarted.

The console indicates longer than expected transaction times are occurring, but I’m unsure of the cause.

There will be multiple entries in the console of something like this:

Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 5.340000 seconds

Any ideas as to what could the the cause/fix?

We need the DEBUG PMS server logs which capture this happening to figure it out.

Settings -server - Troubleshooting - Download Logs

will give you a ZIP file.

That file, captured when this is happening, will let us see.

Plex Media Server Logs_2025-07-23_11-34-49.zip (3.4 MB)
Hello, here is about 5 minutes of logs shortly after uploading an item to the movies library.

It always becomes stuck halfway updating the metadata on whatever item I add.

Did you delete or move a whole bunch of media and put it in a new section?

PMS is deleting it and adding it back with new ID numbers.
It’s struggling because it’s thrashing the DB pretty hard

Jul 23, 2025 11:26:11.260 [140075340704568] WARN - [Req#e514] SLOW QUERY: It took 320.000000 ms to retrieve 90 items.
Jul 23, 2025 11:26:11.263 [140075333626680] WARN - [Req#e520] SLOW QUERY: It took 350.000000 ms to retrieve 90 items.
Jul 23, 2025 11:26:11.276 [140075284433720] WARN - [Req#e518] SLOW QUERY: It took 260.000000 ms to retrieve 90 items.
.
.
.
Jul 23, 2025 11:26:17.240 [140075333626680] WARN - [Req#e586] SLOW QUERY: It took 310.000000 ms to retrieve 90 items.
Jul 23, 2025 11:26:17.241 [140075360324408] WARN - [Req#e593] SLOW QUERY: It took 320.000000 ms to retrieve 90 items.
Jul 23, 2025 11:26:17.244 [140075284433720] WARN - [Req#e588] SLOW QUERY: It took 290.000000 ms to retrieve 90 items.
Jul 23, 2025 11:26:17.299 [140075621407544] DEBUG - Completed: [192.168.50.194:63050] 200 GET /library/sections/1/all?sort=addedAt:desc&contentDirectoryID=1&pinnedContentDirectoryID=2%2C3%2C4%2C5%2C1%2C7%2C8%2C9%2C11%2C13 (10 live) #e588 TLS GZIP Page 0-89 149ms 40489 bytes (pipelined: 8)
Jul 23, 2025 11:26:17.303 [140075621407544] DEBUG - Completed: [192.168.50.194:63052] 200 GET /library/sections/5/all?sort=addedAt:desc&contentDirectoryID=5&pinnedContentDirectoryID=2%2C3%2C4%2C5%2C1%2C7%2C8%2C9%2C11%2C13 (10 live) #e593 TLS GZIP Page 0-89 155ms 39607 bytes (pipelined: 9)
Jul 23, 2025 11:26:17.304 [140075621407544] DEBUG - Completed: [192.168.50.194:63054] 200 GET /library/sections/8/all?sort=addedAt:desc&contentDirectoryID=8&pinnedContentDirectoryID=2%2C3%2C4%2C5%2C1%2C7%2C8%2C9%2C11%2C13 (10 live) #e586 TLS GZIP Page 0-89 154ms 41077 bytes (pipelined: 6)
Jul 23, 2025 11:26:17.521 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:17.521 [140075371297592] DEBUG - Deleting media item 465547.
Jul 23, 2025 11:26:17.808 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442354.
Jul 23, 2025 11:26:19.390 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.730000 seconds
Jul 23, 2025 11:26:19.963 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:19.963 [140075371297592] DEBUG - Deleting media item 465548.
Jul 23, 2025 11:26:20.290 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442353.
Jul 23, 2025 11:26:21.886 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.820000 seconds
Jul 23, 2025 11:26:22.450 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:22.450 [140075371297592] DEBUG - Deleting media item 465549.
Jul 23, 2025 11:26:22.745 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442352.
Jul 23, 2025 11:26:24.320 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.730000 seconds
Jul 23, 2025 11:26:24.887 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:24.887 [140075371297592] DEBUG - Deleting media item 465550.
Jul 23, 2025 11:26:25.187 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442351.
Jul 23, 2025 11:26:26.772 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.760000 seconds
Jul 23, 2025 11:26:27.343 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:27.343 [140075371297592] DEBUG - Deleting media item 465551.
Jul 23, 2025 11:26:27.661 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442350.
Jul 23, 2025 11:26:29.248 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.790000 seconds
Jul 23, 2025 11:26:29.811 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:29.811 [140075371297592] DEBUG - Deleting media item 465552.
Jul 23, 2025 11:26:30.103 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442349.
Jul 23, 2025 11:26:31.690 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.740000 seconds
Jul 23, 2025 11:26:32.256 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:32.256 [140075371297592] DEBUG - Deleting media item 465553.
Jul 23, 2025 11:26:32.552 [140075371297592] DEBUG - Was connected to metadata item 5189, count is now 442348.
Jul 23, 2025 11:26:34.144 [140075371297592] WARN - Held transaction for too long (/home/runner/_work/plex-media-server/plex-media-server/Library/MediaItem.cpp:885): 3.770000 seconds
Jul 23, 2025 11:26:34.716 [140075371297592] DEBUG - Updating deletion state for metadata item 5189, is has a dead item count of 0.
Jul 23, 2025 11:26:34.716 [140075371297592] DEBUG - Deleting media item 465554.

It might just be the DB is very badly fragmented.

How big are the DB’s (as seen in FileStation) ?

I have not deleted a large number of items or moved anything.

Here is a screenshot of the DB folder in file station.

Hello, @ChuckPa How would I go about fixing this? Currently, I have to add a movie, then stop the server once it discovers the movie, before adding another movie. Otherwise, it just gets stuck adding the one media object forever.

I’ve tried database optimization under troubleshooting and letting a library scan run for 12 hours, thinking it was just queued up jobs, but this did not resolve the issue.

You need to look at your file naming and make sure it complies with the Plex recommended naming and you also need to check your file encoding.

Your logs show some issues in both areas and these issues will contribute to the scanning issues you have reported.

From your logs:

Feb 20, 2022 02:03:28.105 [0x7f6184ba2848] ERROR - [FFMPEG] - EBML header parsing failed
Feb 20, 2022 02:03:28.106 [0x7f6184ba2848] ERROR - Exception analyzing media file '/volume1/MEDIA/Anime/ Elfen Lied/Elfen Lied - 02.mkv' (Could not parse /volume1/MEDIA/Anime/ Elfen Lied/Elfen Lied - 02.mkv (error=-1094995529): Invalid data found when processing input)

The above shows both a naming issue (most Anime should be named as a TV Series) and the file shown is also poorly encoded.

E.G. /volume1/MEDIA/Anime/Elfen Lied/Season 01/Elfen Lied - S01E02.mkv
                         ^ Remove the leading space here

https://support.plex.tv/articles/categories/your-media/

I recommend using Handbrake to re-encode your files with, preferably to .mp4 H.264/AAC.

I also highly recommend using FileBot to automatically rename and organise your media with. Well worth the money IMHO.

Check your Plex Scanner and Deep Analysis logs for signs of more problem files.

Hello, I did correct that issue and the problem is still there. I do have another theory, as I was able to reproduce the long transaction problem without modifying the library. I have separate movie/anime/tv show, ect library’s, so I’m unsure why Anime would even be scanned when adding a movie.

I have a specific movie that I tried to delete and replace with another, but the movie will not delete out of the library on the Plex side, despite the file no longer existing. I get an error when trying to remove it from the library. When I try to do anything with this like update metadata/match it/delete it from Plex, it goes through the loop again and I can see it in the console logs.



image

Could it be that its trying to delete this file over and over again but it can’t because it doesn’t exist?
Plex Media Server Logs_2025-07-28_13-56-23.zip (3.2 MB)

@techsteve

See if you can determine which file is metadata item 5189 (from the recurring log entry).

Add your X-Plex-Token and enter this into a browser: https://192.168.50.8:32400/library/metadata/5189?X-Plex-Token=

For example, if your X-Plex-Token is abc123, use https://192.168.50.8:32400/library/metadata/5189?X-Plex-Token=abc123

It should return the XML info for the item, which will contain the file name and path to the file.

Curious if it is Watchmen or some other media file on your server.


To find your X-Plex-Token: https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/

NOTE: Do not display your X-Plex-Token in this forum or any public space. It can be used to gain access to your server.

Hi @FordGuy61 I was able to get the token and complete the URL https://192.168.50.8:32400/library/metadata/5189?X-Plex-Token=MYTOKENFROMXML. When I go to that it gives me an invalid cert warning. When I bypass and proceed anyway, it just loads forever and nothing happens.

@techsteve

If you can pull the DB (PMS stopped) to a computer with SQLite3,
you can query it to find what that number is pointing to.

I can give you the SQL to do that.

Interested?

Hi @ChuckPa I am interested. Can you share the instructions/commands for that?

Thank you!