How to repair database on docker install?

Server Version#: 1.23.5.4801
Player Version#: N/A

My database is exhibiting some wonky behaviour. It stopped doing automatic backups during scheduled tasks, and I see a bunch of errors in the logs when I optimize the database, like below. I think it would be worth repairing or rebuilding the database, but how do I do this with a docker install? The SQL tools are inside the container, but if I stop PMS, the container shuts down. And starting the container again obviously starts PMS again. I’m sure there’s a solution to this other than an actual local non-docker install of PMS, but I’m just missing it.

Timestamp Level Message
Jul 19, 2021 11:50:18.259 ERROR [EventSourceClient/pubsub] Retrying in 15 seconds.
Jul 19, 2021 11:50:18.259 ERROR [EventSourceClient/mediaserver] Retrying in 15 seconds.
Jul 19, 2021 11:50:18.256 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.254 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.252 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.250 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.248 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.246 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.244 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.242 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.240 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.234 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.232 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.230 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.228 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.226 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.224 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.222 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.220 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.216 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:50:18.212 INFO [Database optimization/com.plexapp.plugins.library.db] SQLITE3:0x80000001, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Jul 19, 2021 11:49:57.356 WARN [Database optimization/com.plexapp.plugins.library.db] Held transaction for too long (…/Library/FullTextSearch.cpp:90): 3.370000 seconds
Jul 19, 2021 11:49:53.923 WARN [Database optimization/com.plexapp.plugins.library.db] Held transaction for too long (…/Library/FullTextSearch.cpp:80): 5.670000 seconds
Jul 19, 2021 11:49:48.148 WARN [Database optimization/com.plexapp.plugins.library.db] Held transaction for too long (…/Library/FullTextSearch.cpp:69): 4.490000 seconds
Jul 19, 2021 11:49:43.508 WARN [Database optimization/com.plexapp.plugins.library.db] Held transaction for too long (…/Library/FullTextSearch.cpp:59): 22.900000 seconds
Jul 19, 2021 11:49:20.258 WARN [Database optimization/com.plexapp.plugins.library.db] Held transaction for too long (…/Library/DatabaseFixups.cpp:213): 0.580000 seconds
Jul 19, 2021 11:49:05.288 WARN QueryParser: Invalid field ‘sectionID’ found, ignoring.
Jul 19, 2021 11:49:05.288 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:05.288 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.918 WARN QueryParser: Invalid field ‘sectionID’ found, ignoring.
Jul 19, 2021 11:49:04.918 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.918 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.878 WARN QueryParser: Invalid field ‘sectionID’ found, ignoring.
Jul 19, 2021 11:49:04.878 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.878 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.856 WARN QueryParser: Invalid field ‘sectionID’ found, ignoring.
Jul 19, 2021 11:49:04.856 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.856 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘sectionID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘sectionID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.833 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.602 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.602 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.163 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.163 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.106 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:04.106 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.990 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.990 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.989 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.989 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.746 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.746 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.726 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.726 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.704 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.704 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.674 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.674 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.662 WARN QueryParser: Invalid field ‘contentDirectoryID’ found, ignoring.
Jul 19, 2021 11:49:03.662 WARN QueryParser: Invalid field ‘pinnedContentDirectoryID’ found, ignoring.
  1. Schema changes happen with every update
  2. Index fields are rebuilt after every database optimization
  3. The DB traffic shown there is normal. The DB does not appear to need repair but more logs (not just an excerpt) would prove that out.
  4. Of concern are the first two lines:
Jul 19, 2021 11:50:18.259 	ERROR 	[EventSourceClient/pubsub] Retrying in 15 seconds.
Jul 19, 2021 11:50:18.259 	ERROR 	[EventSourceClient/mediaserver] Retrying in 15 seconds.

This is a network connectivity problem reaching Plex.tv and likely root issue.

Thanks for your help, Chuck! Excellent as always and I appreciate it. What would you like me to provide, and how, to verify whether DB needs repair? And if it did need repair, how would that be done with a docker install?

If the logs show “Image is malformed” then you definitively know the DB is damaged.
PMS will refuse to start.

You’ll get about 10 lines in the logs then :boom:

You need to repair it external to the container and that’s where it gets fun.

  1. Install PMS but do not use (stop it)
  2. Use /usr/lib/plexmediaserver/Plex SQLite with the DB file ---- As seen from outside the container.
  • The container won’t start if the DB is damaged.

Thanks Chuck. So if I’m understanding correctly, as long as PMS starts, the issue is not DB corruption and a DB repair is not needed. And a local install of PMS would be needed for repairs, because there’s no way to use just the docker container to do a repair - so let’s hope I don’t need to!

In that case, any ideas on why PMS would not be doing the backups every three days? It would be nice if Plex would send me a notification if there was a failed or missed backup, because I tend to not find out until everything goes to hell and there haven’t been any backups for months (I have had this happen several times over the past many years with Plex). Yes, I could theoretically write some sort of script that is run by cron to check for recent backups. No, I don’t have any scripting experience. :slight_smile:

You are correct.

There have been a few, RARE, cases where there was damage down deep (bad values written to data tables) but those were cured by deleting and recreating sections.

Scripting is not tough.
Think about what you type at the command line – Put it in a file.

Easy - peasy :slight_smile:

Fancy scripting takes more time to learn but not much

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