Stuck... Can't access nor remove photo libraries nor optimize database

My photo libraries can not be accessed, “There was an unexpected error loading this library”. These libraries also can not be removed - the delete library dialog has a perpetually spinning icon on the red button. Finally I tried to optimize database and that did not complete leaving it to run overnight. Music, TV and Movies portions of Plex all seem normal/usable.

I have read a ton of different posts on these topics and can’t find the path forward. Running the latest PMS on QNAP TVS-471 with QTS 4.2.3. Logs attached. Thanks in advance.

You will need to adapt one of these two procedures to manually optimize your database.

I suggest you try the first method because it’s the easiest.

On QNAP, your Preferences.xml file will be stored under <SystemShare>/.qpkg/PlexMediaServer

You want to extract your PlexOnlineToken and build a command to place in your browser address line as shown.

It will look like: http://ip.addr.of.qnap:32400/library/optimize?async=1&X-Plex-Token=YourTokenHere

Thanks ChuckPA. Giving it a try. Webpage results in a blank screen and PMS does not appear to recognize any optimization activity. How long should I wait? I did try to access and delete again after just a few minutes and the results were unchanged.

For others, my .xml was located here:

/share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server

After waiting 12+ hours, there is no change in my original problem/description. Any further advice?

If you cannot optimize the database manually

Procedure: https://forums.plex.tv/discussion/277716/manual-database-optimization-using-command-line

Your X-Plex-Token is your PlexOnlineToken and found in /share/CACHEDEV1_DATA/.qpkg/PlexMediaServer/Library/Plex Media Server/Preferences.xml

You need not be in the QNAP shell to do this… Supply the IP addr of the QNAP in the URL and it will be the same. (The curl command)

If this doesn’ t work, your only recourse is to start over. When you do, add photos in much smaller blocks and Optimize Database between blocks. Did you add 20,000+ in one shot? If so, that will bury it.

I will give that a try. However, there was no large changes to photo directories that preceded this state.

Anyway to maintain collections for movies if starting from scratch? Is there a best practice for starting from scratch on QNAP?

I had the token available for copy/paste so just tried this from NAS

curl --request PUT http://127.0.0.1:32400/library/optimize?async=1&X-Plex-Token=mytoken

Got a blank command line afterward with no feedback. Is that expected? Can I find out if optimization is occurring/occured?

Thanks much.

it should not give any errors or other output. This is because it’s Async. The server takes the command and runs with it.

If you manually look at Plex Media Server.log, you should see the database activity in the log.

Situation has worsened. After another user added some photos to one of the directories in the non-working Libraries, the Movies and TV libraries began throwing the same errors. Then PMS became unaccessible. Stopped and started it on the QTS GUI to no avail. Looks like a total fresh install. What a massive bummer… Is there any recommended backup procedure that could help prevent such a total fresh start and reconfiguration?

If it doesn’t respond to you, backing it up will do no good because the core of the problem is the database.

The best option is to:

Stop PMS,
Install SQLite3 on the QNAP.
Manually optimize the database from the command line (dump it to a text file and recreate the DB from the SQL… which is easily done)
Restart PMS

What is strange is that, from your logs, PMS seems to update photo libraries without problems. Some points that I’ve noticed from logs:

  1. Are you running with a fixed IP ? Or with DHCP ? I’ve noticed several messages reporting network changes
  2. Do you have a large network ? What is your netmask ? Looks like you may be using 255.255.0.0 when usually this is 255.255.255.0 (not a problem, just curiosity)
  3. From your folder names I’m not sure if you are using only .mp4 and .jpg for files (are you including other file types) ? I think I saw a spreedsheet folder among the others
    Being a plex pass user you have the advantage of PMS taking backups every 3 days (unless you disable it), you may restore the database following instructions here

@moody_blue said:
What is strange is that, from your logs…

Thanks. I went for a full reinstall and problem is gone. If there is preventative measures possible let me answer your questions.

  • Mac and NAS both have fixed IP addresses
  • Not a large network, small home network
  • NAS does have submask 255.255.0.0, local Mac has 255.255.255.0
  • Video file types are mixed. Photo file type are mostly ,jpg but in some of those folders there are video, spreadsheet, pdf and other various documents

@swamp2 said:
Thanks. I went for a full reinstall and problem is gone. If there is preventative measures possible let me answer your questions.

As a Plex Pass user, your database is backed up automatically!
Due to that, if discovered in time, restore that.

support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/