Com.plexapp.plugins.library.db SQL corruption

Server Version#:v1.21.1.3830
Player Version#:

Hi there.

I have a Plex server which has been running for quite a while now.

The server reported SQL corruption errors, so I tried restoring a backup version of the com.plexapp.plugins.library.db file. I still get an error when trying this;

Dec 22, 2020 01:23:06.811 [0x70000ed5c000] INFO - /Applications/Plex Media Server.app/Contents/MacOS/Plex Media Server

Dec 22, 2020 01:23:07.018 [0x70000ef68000] DEBUG - BPQ: [Idle] -> [Starting]

Dec 22, 2020 01:23:08.204 [0x70000f0f1000] DEBUG - Job running: ‘/Applications/Plex Media Server.app/Contents/MacOS/CrashUploader’ ‘–directory=/Users/khetan/Library/Application Support/Plex Media Server/Crash Reports/1.21.1.3830-6c22540d5’ ‘–version=1.21.1.3830-6c22540d5’ ‘–platform=MacOSX’ ‘–platformVersion=10.15.7’ ‘–serverUuid=be12af4880e95ce71f544637ba5705ab750104f0’ ‘–userId=khetan@os.org.za’ ‘–sentryUrl=https://sentry.io/api/1233455/minidump’ ‘–sentryKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ ‘–vendor=Apple’ ‘–model=x86_64’ ‘–device=Mac’ ‘–allowRetries=0’

Dec 22, 2020 01:23:08.205 [0x70000f0f1000] DEBUG - Jobs: Starting child process with pid 18745

Dec 22, 2020 01:23:08.263 [0x70000ef68000] DEBUG - FeatureManager: Using cached data for features list

Dec 22, 2020 01:23:08.269 [0x70000ef68000] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.26.0, threadsafe=1

Dec 22, 2020 01:23:08.270 [0x70000ef68000] ERROR - SQLITE3:0x10e546d38, 26, file is not a database in “PRAGMA cache_size=2000”

Dec 22, 2020 01:23:08.270 [0x70000ef68000] ERROR - Database corruption: sqlite3_statement_backend::prepare: file is not a database for SQL: PRAGMA cache_size=2000

I have tried the repair process, but receive an error;
khetan@kgimac2 Databases % sqlite3 com.plexapp.plugins.library.db “DROP index ‘index_title_sort_naturalsort’”

Error: file is not a database

Unfortunately the same thing happens no matter how early back I go in the backups.

Any tips ?

Seems if I restore from a backup two versions back from the latest, I can go through the corruption repair, export/import of SQL. But then PMS throws this error;
Dec 22, 2020 01:27:16.818 [0x70000fc72000] INFO - Plex Media Server v1.21.1.3830-6c22540d5 - Apple Mac x86_64 - build: darwin-x86_64 macos - GMT 02:00

Dec 22, 2020 01:27:16.818 [0x70000fc72000] INFO - MacOSX version: 10.15.7, language: en-GB

Dec 22, 2020 01:27:16.818 [0x70000fc72000] INFO - Processor Intel® Core™ i7-4771 CPU @ 3.50GHz

Dec 22, 2020 01:27:16.818 [0x70000fc72000] INFO - /Applications/Plex Media Server.app/Contents/MacOS/Plex Media Server

Dec 22, 2020 01:27:17.566 [0x70000fe7e000] DEBUG - BPQ: [Idle] -> [Starting]

Dec 22, 2020 01:27:17.587 [0x70000fe7e000] DEBUG - FeatureManager: Using cached data for features list

Dec 22, 2020 01:27:17.633 [0x70000fe7e000] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.26.0, threadsafe=1

Dec 22, 2020 01:27:17.634 [0x70000fe7e000] ERROR - SQLITE3:0x1028c5d38, 26, file is not a database in “PRAGMA cache_size=2000”

Dec 22, 2020 01:27:17.634 [0x70000fe7e000] ERROR - Database corruption: sqlite3_statement_backend::prepare: file is not a database for SQL: PRAGMA cache_size=2000

I’ve now restored a com.plexapp.plugins.library.db file from two weeks ago, and it repairs correctly;

khetan@kgimac2 Databases % sqlite3 com.plexapp.plugins.library.db “DROP index ‘index_title_sort_naturalsort’”
khetan@kgimac2 Databases % sqlite3 com.plexapp.plugins.library.db “DELETE from schema_migrations where version=‘20180501000000’”
khetan@kgimac2 Databases % sqlite3 com.plexapp.plugins.library.db .dump > dump.sql
khetan@kgimac2 Databases % rm com.plexapp.plugins.library.db
khetan@kgimac2 Databases % sqlite3 com.plexapp.plugins.library.db < dump.sql
khetan@kgimac2 Databases % rm com.plexapp.plugins.library.db-shm
khetan@kgimac2 Databases % rm com.plexapp.plugins.library.db-wal

But, when I start Plex Media Server up, I get the following error;

Blockquote
Dec 22, 2020 13:19:41.715 [0x70000e7f5000] INFO - Plex Media Server v1.21.1.3830-6c22540d5 - Apple Mac x86_64 - build: darwin-x86_64 macos - GMT 02:00

Dec 22, 2020 13:19:41.715 [0x70000e7f5000] INFO - MacOSX version: 10.15.7, language: en-GB

Dec 22, 2020 13:19:41.715 [0x70000e7f5000] INFO - Processor Intel(R) Core™ i7-4771 CPU @ 3.50GHz

Dec 22, 2020 13:19:41.715 [0x70000e7f5000] INFO - /Applications/Plex Media Server.app/Contents/MacOS/Plex Media Server

Dec 22, 2020 13:19:41.898 [0x70000ea01000] DEBUG - BPQ: [Idle] → [Starting]

Dec 22, 2020 13:19:42.376 [0x70000ea01000] DEBUG - FeatureManager: Using cached data for features list

Dec 22, 2020 13:19:42.380 [0x70000ea01000] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.26.0, threadsafe=1

Dec 22, 2020 13:19:43.073 [0x70000ea01000] DEBUG - Running migrations. (EPG 0)

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Running forward migration 20180501000000.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 0.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 1.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 2.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 3.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 4.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 5.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 6.
Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 7.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 8.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 9.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 10.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 11.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 12.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 13.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 14.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 15.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 16.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 17.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 18.

Dec 22, 2020 13:19:43.074 [0x70000ea01000] DEBUG - Captured session 19.

Dec 22, 2020 13:19:43.213 [0x70000ea01000] WARN - Held transaction for too long (…/Library/DatabaseMigrations.cpp:209): 0.140000 seconds

Dec 22, 2020 13:19:43.217 [0x70000ea01000] DEBUG - Analyzing database.

Dec 22, 2020 13:19:43.473 [0x70000eb8a000] DEBUG - Job running: ‘/Applications/Plex Media Server.app/Contents/MacOS/CrashUploader’ ‘–directory=/Users/khetan/Library/Application Support/Plex Media Server/Crash Reports/1.21.1.3830-6c22540d5’ ‘–version=1.21.1.3830-6c22540d5’ ‘–platform=MacOSX’ ‘–platformVersion=10.15.7’ ‘–serverUuid=be12af4880e95ce71f544637ba5705ab750104f0’ ‘–userId=khetan@os.org.za’ ‘–sentryUrl=https://sentry.io/api/1233455/minidump’ ‘–sentryKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’ ‘–vendor=Apple’ ‘–model=x86_64’ ‘–device=Mac’ ‘–a
llowRetries=0’

Dec 22, 2020 13:19:43.496 [0x70000eb8a000] DEBUG - Jobs: Starting child process with pid 21293

Dec 22, 2020 13:19:43.536 [0x70000eb07000] DEBUG - Jobs: ‘/Applications/Plex Media Server.app/Contents/MacOS/CrashUploader’ exit code for process 21293 is 0 (success)

Dec 22, 2020 13:19:43.590 [0x70000ea01000] DEBUG - Vacuuming database.

Dec 22, 2020 13:21:41.895 [0x70000e878000] DEBUG - BPQ: [Starting] → [Processing]

Dec 22, 2020 13:22:34.620 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.622 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.623 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.624 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.625 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has ch
anged

Dec 22, 2020 13:22:34.626 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.627 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.628 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.630 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.631 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.632 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.634 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.635 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, state
ment aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.636 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.637 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.638 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.639 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.641 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.642 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Completed forward migration 20180501000000.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Running forward migration 202
00921130000.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 0.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 1.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 2.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 3.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 4.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 5.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 6.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 7.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 8.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 9.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 10.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 11.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 12.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 13.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 14.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 15.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 16.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 17.

Dec 22, 2020 13:22:34.643 [0x70000ea01000] DEBUG - Captured session 18.

Dec 22, 2020 13:22:34.645 [0x70000ea01000] DEBUG - Captured session 19.

Dec 22, 2020 13:22:34.657 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has ch
anged

Dec 22, 2020 13:22:34.659 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.660 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.661 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.663 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.664 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.665 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.666 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.667 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, state
ment aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.669 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.670 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.672 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.673 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.674 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.675 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.676 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
Dec 22, 2020 13:22:34.677 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.678 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.682 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.683 [0x70000ea01000] DEBUG - Completed forward migration 20200921130000.

Dec 22, 2020 13:22:34.688 [0x70000e878000] DEBUG - BPQ: generating queue items from 31 generator(s)

Dec 22, 2020 13:22:34.689 [0x70000e878000] DEBUG - BPQ: generated 0 item(s) for queue

Dec 22, 2020 13:22:34.690 [0x70000e878000] DEBUG - PlayQueue: 0 generated IDs compressed down to a 20 byte blob.

Dec 22, 2020 13:22:34.690 [0x70000e878000] DEBUG - PlayQueue: 0 generated IDs compressed down to a 20 byte blob.

Dec 22, 2020 13:22:34.691 [0x70000e878000] DEBUG - BPQ: [Processing] → [Idle]

Dec 22, 2020 13:22:34.706 [0x70000ea01000] DEBUG - ChangestampAllocator: initialized to 8447731

Dec 22, 2020 13:22:34.706 [0x70000ea01000] DEBUG - Opening 2 database sessions t
Dec 22, 2020 13:22:34.682 [0x70000ea01000] INFO - SQLITE3:0x102d1bd38, 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed

Dec 22, 2020 13:22:34.683 [0x70000ea01000] DEBUG - Completed forward migration 20200921130000.

Dec 22, 2020 13:22:34.688 [0x70000e878000] DEBUG - BPQ: generating queue items from 31 generator(s)

Dec 22, 2020 13:22:34.689 [0x70000e878000] DEBUG - BPQ: generated 0 item(s) for queue

Dec 22, 2020 13:22:34.690 [0x70000e878000] DEBUG - PlayQueue: 0 generated IDs compressed down to a 20 byte blob.

Dec 22, 2020 13:22:34.690 [0x70000e878000] DEBUG - PlayQueue: 0 generated IDs compressed down to a 20 byte blob.

Dec 22, 2020 13:22:34.691 [0x70000e878000] DEBUG - BPQ: [Processing] → [Idle]

Dec 22, 2020 13:22:34.706 [0x70000ea01000] DEBUG - ChangestampAllocator: initialized to 8447731

Dec 22, 2020 13:22:34.706 [0x70000ea01000] DEBUG - Opening 2 database sessions to library (com.plexapp.plugins.library.blobs), SQLite 3.26.0, threadsafe=1

Dec 22, 2020 13:22:34.820 [0x70000ea01000] ERROR - SQLITE3:0x102d1bd38, 26, file is not a database in “PRAGMA cache_size=2000”

Dec 22, 2020 13:22:34.825 [0x70000ea01000] ERROR - Database corruption: sqlite3_statement_backend::prepare: file is not a database for SQL: PRAGMA cache_size=2000

I have also restored back the Plex Application from the time of the backup, in case that was the issue. Still seeing an error.