Recently my server scans have been getting stuck, it’s weird though as it is not every time which makes me think it is not a corrupt file or anything but is a completely different cause.
Right now my music library scan is stuck, I have not added any new music for a week or so and it had been scanning fine for a while.
I have looked through the attached logs and there is some behaviour that seems strange is the Plex Media Server 2 log file.
Basically the libraries had been scanning every 15-30 mins or so and then suddenly the scan seem to stop actually doing anything at around Mar 14, 2018 23:17:16.619 and then all subsequent scans seem to say ‘Library Updater: Section 2 is already being updated.’ and it never seems to recover.
Once this happens at the moment the only way I have been able to fix it is by restarting my NAS completely. Stopping the Plex process doesn’t seem to actually stop the process at all, presumably because some scan is busy doing something, so restarting is the only way to get it to stop.
Any ideas? Some help would be greatly appreciated as this is causing me much frustration at the moment!
Thanks 
In the log you referenced, I do see the scanner activity. I also see where the internet connection went down. “EventSource” waits before reporting it to be certain it’s a ‘hard down’. The best analogy to give it is ‘Three retries internally, Report, Hard connection reset, Retry until successful’ . This as the flow, PMS needed some 15 seconds to re-establish connection to plex.tv after performing the hard connection reset which is acceptable.
Mar 14, 2018 23:32:16.622 [0x6edff400] INFO - It's been 44113175 seconds, so we're starting scheduled library update for section 2 (TV Shows)
Mar 14, 2018 23:32:16.622 [0x6edff400] DEBUG - Library Updater: Requested that section 2 be updated, force=0, deep=0, subdir= iTunes=0
Mar 14, 2018 23:32:16.622 [0x6edff400] DEBUG - Library Updater: Section 2 is already being updated.
Mar 14, 2018 23:38:57.521 [0x73511400] DEBUG - EventSource: Failure in IdleTimeout (0 - Success).
Mar 14, 2018 23:38:57.521 [0x73511400] DEBUG - MyPlex: We appear to have lost Internet connectivity, resetting device URL cache.
Mar 14, 2018 23:38:57.521 [0x73511400] ERROR - EventSource: Retrying in 15 seconds.
Mar 14, 2018 23:39:12.522 [0x737ff400] DEBUG - EventSource: Resolving 139.162.202.171 port 443s
Mar 14, 2018 23:39:12.546 [0x737ff400] DEBUG - EventSource: Resolved 139.162.202.171 to 139.162.202.171
Mar 14, 2018 23:39:15.693 [0x73511400] DEBUG - EventSource: Connected in 123 ms.
Mar 14, 2018 23:39:15.694 [0x73511400] DEBUG - EventSource: Wrote data, reading reply.
Mar 14, 2018 23:39:15.791 [0x737ff400] DEBUG - EventSource: Read HTTP reply header.
Mar 14, 2018 23:39:15.791 [0x737ff400] DEBUG - MyPlex: We appear to have regained Internet connectivity.
Mar 14, 2018 23:39:15.791 [0x737ff400] DEBUG - PublicAddressManager: Obtaining public address and mapping port.
I would like you to consider, since you’re on 1.10.0 and if you have the 1.10.0 SPK saved locally just in case this doesn’t work, please try 1.12.0/1.12.1 and see if your results are different. There has been work done there since 1.10.0
Thanks for your response. Not sure why it lost internet connectivity but that is something I can investigate. I had been using the 1.12 version until the weekend and I rolled back to see if it made any difference but the issue seems to occur on both. I will update again to the latest anyway
I have updated to the latest version again. Could not find a cause of the internet connection loss although I did notice my HDDs were set to hibernate, I have now disabled that and will see how things go over the weekend
Okay, it’d been running alright for a few days and this evening it is stuck scanning my music library once again… I can’t see any mention of a loss of internet connection in the logs and I have also been using Plex quite a bit this evening and have not had any issues with playback. Can you see anything in the logs that looks suspicious??
The reason it’s getting slow is because, after adding all the new media, the database is fragmented.
GZIP Signed-in Token (Invincibloobles)
Mar 19, 2018 21:24:25.515 [0x70923400] WARN - SLOW QUERY: It took 240.000000 ms to retrieve 6 items.
Mar 19, 2018 21:24:25.575 [0x70211400] DEBUG - It took 150.000000 ms to retrieve 1 items.
Mar 19, 2018 21:24:25.630 [0x730ff400] WARN - SLOW QUERY: It took 430.000000 ms to retrieve 20 items.
Mar 19, 2018 21:24:25.634 [0x70923400] DEBUG - Activity: registered new activity f751c1ca-4f8e-4008-8b16-8756d3055933 - Refreshing
Mar 19, 2018 21:24:25.652 [0x67711400] WARN - SLOW QUERY: It took 220.000000 ms to retrieve 15 items.
Mar 19, 2018 21:24:25.715 [0x679ff400] DEBUG - Activity: updated activity f751c1ca-4f8e-4008-8b16-8756d3055933 - completed 0% - Refreshing
Mar 19, 2018 21:24:25.720 [0x70211400] WARN - SLOW QUERY: It took 280.000000 ms to retrieve 33 items.
Mar 19, 2018 21:24:25.724 [0x679ff400] DEBUG - Activity: updated activity f751c1ca-4f8e-4008-8b16-8756d3055933 - completed 33% - Refreshing
Stop what it’s doing.
Manually Optimize the Database
Start it again.
I added 4 songs to the music library which is the one that is stuck. And it has scanned since then with no issues. For some reason if I stop the scan and optimise I now cannot start a new scan. The spinning icon which shows during a scan spins for less than a second and then stops. I’ve had this problem each time I have cancelled a stuck scan and he only way I’ve managed to get Plex to scan again has been to restart my entire NAS 
The spinning wheel is telling you PMS is stuck… because your database is so fragmented that PMS’s different parts can’t talk to each other.
Instead of restarting the NAS, you were not able to Stop the package in Package Center?
That does indeed makes sense. Does this mean that the optimise is not working, if the scan won’t start immediately after running an optimise?
If I stop it in the package centre it claims to be stopped but the plex processes still show as sleeping in the process list, and if you start it again they remain asleep. So restarting the NAS itself has been the only way to get the process to actually stop and start fresh
What’s happening internally is:
- one component (Scanner) asks for data.
- Another piece attempts to provide that (Media Provider)
- The media provider lookup attempts to get information for the scanner
- The amount of time required for the ‘provider’ to get the data takes so long, the Scanner gives up waiting for it.
- The scanner continues with the next request.
- Now we have a collision forming. The Provider is still doing the first but therer is another request already waiting.
- Then another and another.
- Traffic gridlock forms all because the database does not respond quickly enough.
- PMS stops responding .
Once the database is optimized, we can restart PMS to it comes back with the expectation of everthing working correctly.
Since all the data is in best form, it works.
You can now restart the scanner and it will resume where it was
Okay, so I optimised the database. I then went to the Package Center on the NAS and stopped plex. But for whatever reason plex is still running. The package shows as stopped but there are multiple plex processes still showing in the processes window. I then ran plex again but although the plex package shows as running, I get this message when trying to access the server: “The server “synology_ce” is unavailable. Plex will automatically try to reconnect to this.”
The only way I ever seem to be able to get plex to work again once this happens is to restart the NAS itself. This is the loop I seem to be stuck in. I optimise plex, restart the NAS, plex restarts and works fine for a few days. Then a scan gets stuck. I cancel the scan, optimise, try and stop plex but it doesn’t actually stop but now wont run again either. I have to restart the NAS. I’ve basically been in this cycle for 10 days or so now and don’t really know what to do
As one last effort, before resorting to the unpleasant DSM re-install (does not erase your data), let’s try one last thing
- Uninstall the package.
- Power down, not just restart, the NAS
- Power up
- Install PMS
If this does not clear the control data entries in DSM, there is no choice but to reset/reinstall the OS. Again, this won’t erase your data.
Apologies here: I am currently mobile. I will return to the office in s few hours. I wanted to reply while waiting 
Sent from iPhone
On Mar 20, 2018, at 05:39, Invincibloobles forums+d313344-s6025034@plex.tv wrote:
Plex Forums https://forums.plex.tv/
Invincibloobles commented on Server scans keep getting stuck
Okay, so I optimised the database. I then went to the Package Center on the NAS and stopped plex. But for whatever reason plex is still running. The package shows as stopped but there are multiple plex processes still showing in the processes window. I then ran plex again but although the plex package shows as running, I get this message when trying to access the server: “The server “synology_ce” is unavailable. Plex will automatically try to reconnect to this.”
The only way I ever seem to be able to get plex to work again once this happens is to restart the NAS itself. This is the loop I seem to be stuck in. I optimise plex, restart the NAS, plex restarts and works fine for a few days. Then a scan gets stuck. I cancel the scan, optimise, try and stop plex but it doesn’t actually stop but now wont run again either. I have to restart the NAS. I’ve basically been in this cycle for 10 days or so now and don’t really know what to do
Appreciate the response! I will give this a shot when I get home and let you know how it goes. I imagine this will make it work again for a few days at least (based on recent experience) so if the issue does manifest itself again it’ll probably be in a few days
It seems to now be stuck on the film library. It has a single film in it D:
it is busy processing music
/volume1/music/Suicide Silence/You Can't Stop Me (Bonus Track Version)/12 Ouroboros.m4a)
That’s weird, the spinning icon is showing next to the films library. However it still managed to update itself overnight as the new TV content has now appeared. So maybe it is no longer stuck and the UI is just wrong?
Which logs do you look at to determine where its stuck, is it the Media scanner deep analysis ones?
If it gets stuck again is the only option to reinstall the OS?