Plex 1.18 corrupted DB (Fix in thread)

Server Version#: 1.18.0.1913-e5cc93306

I just installed the latest update and my media server won’t start now, saying the database is corrupt. The following line is reported in my server log:

Database corruption: sqlite3_statement_backend::prepare: no such column: library_sections.content_changed_at for SQL: select max(max(library_sections.changed_at),max(library_sections.content_changed_at)) from library_sections

Restoring from yesterday’s backup does not work, I get the same corruption error.

Neither my current database nor yesterday’s backup has the content_changed_at column referred to in the log.

I can do the following successfully in sqlite3:

select changed_at from library_sections;

But the following fails with no such column:

select content_changed_at from library_sections;

1 Like

https://support.plex.tv/articles/201100678-repair-a-corrupt-database/

You should perform this procedure in full, just to be on the safe side.

This is quite puzzling. And no, normally there should be no need to remove the ‘naturalsort’ collation from the DB, in order to finish the DB migration.
I have reported your observations.

1 Like

Version 1.18.0.1944
Using Arch Linux, installed via AUR
Up to date according to Public channel

I’m running into this problem as well, but none of the suggestions seem to be working here.

The error (shown at all steps):

  what():  sqlite3_statement_backend::prepare: no such column: library_sections.content_changed_at for SQL: select library_sections.id as 'library_sections_id', library_sections.library_id as 'library_sections_library_id', library_sections.name as 'library_sections_name', library_sections.name_sort as 'library_sections_name_sort', library_sections.section_type as 'library_sections_section_type', library_sections.language as 'library_sections_language', library_sections.agent as 'library_sections_agent', library_sections.scanner as 'library_sections_scanner', library_sections.user_thumb_url as 'library_sections_user_thumb_url', library_sections.user_art_url as 'library_sections_user_art_url', library_sections.user_theme_music_url as 'library_sections_user_theme_music_url', library_sections.created_at as 'library_sections_created_at', library_sections.updated_at as 'library_sections_updated_at', library_sections.scanned_at as 'library_sections_scanned_at', library_sections.user_fields as 'library_sections_user_fields', library_sections.query_xml as 'library_sections_query_xml', library_sections.query_type as 'library_sections_query_type', library_sections.uuid as 'library_sections_uuid', library_sections.changed_at as 'library_sections_changed_at', library_sections.content_changed_at as 'library_sections_content_changed_at' from library_sections
****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: /root/Library/Application Support/Plex Media Server/Crash Reports/1.18.0.1944-f2cae8d6b/PLEX MEDIA SCANNER/69390c96-cd17-c741-38cf14fa-6b329091.dmp

Trying to delete the index as shown above:

sqlite> .indices metadata_items 
index_metadata_items_on_absolute_index 
index_metadata_items_on_added_at 
index_metadata_items_on_changed_at 
index_metadata_items_on_created_at 
index_metadata_items_on_deleted_at 
index_metadata_items_on_guid 
index_metadata_items_on_hash 
index_metadata_items_on_index 
index_metadata_items_on_library_section_id 
index_metadata_items_on_library_section_id_and_metadata_type_and_added_at 
index_metadata_items_on_metadata_type 
index_metadata_items_on_original_title 
index_metadata_items_on_originally_available_at 
index_metadata_items_on_parent_id 
index_metadata_items_on_remote 
index_metadata_items_on_resources_changed_at 
index_metadata_items_on_title 
index_metadata_items_on_title_sort 
index_title_sort_naturalsort 
sqlite> DROP INDEX ‘index_title_sort_naturalsort’; 
Error: no such index: ‘index_title_sort_naturalsort’ 
sqlite>

So sqlite can both see and not see the index in question. Really weird. I proceed with database repair:

[root@umbra Databases]# systemctl stop plexmediaserver
[root@umbra Databases]# rm com.plexapp.plugins.library.db
[root@umbra Databases]# cp com.plexapp.plugins.library.db.original com.plexapp.plugins.library.db
[root@umbra Databases]# rm dump.sql
[root@umbra Databases]# sqlite3 com.plexapp.plugins.library.db "DROP index 'index_title_sort_naturalsort'"
[root@umbra Databases]# sqlite3 com.plexapp.plugins.library.db "DELETE from schema_migrations where version='20180501000000'"
[root@umbra Databases]# sqlite3 com.plexapp.plugins.library.db .dump > dump.sql
[root@umbra Databases]# rm com.plexapp.plugins.library.db
[root@umbra Databases]# sqlite3 com.plexapp.plugins.library.db < dump.sql
[root@umbra Databases]# chown plex:plex com.plexapp.plugins.library.db
[root@umbra Databases]# mv com.plexapp.dlna.db-shm com.plexapp.dlna.db-shm.old
[root@umbra Databases]# mv com.plexapp.dlna.db-wal com.plexapp.dlna.db-qal.old
[root@umbra Databases]# systemctl start plexmediaserver

No errors, great. Let’s try to run the scanner again:

[root@umbra Databases]# /usr/lib/plexmediaserver/Plex\ Media\ Scanner --list
terminate called after throwing an instance of 'soci::soci_error'
  what():  sqlite3_statement_backend::prepare: no such column: library_sections.content_changed_at for SQL: select library_sections.id as 'library_sections_id', library_sections.library_id as 'library_sections_library_id', library_sections.name as 'library_sections_name', library_sections.name_sort as 'library_sections_name_sort', library_sections.section_type as 'library_sections_section_type', library_sections.language as 'library_sections_language', library_sections.agent as 'library_sections_agent', library_sections.scanner as 'library_sections_scanner', library_sections.user_thumb_url as 'library_sections_user_thumb_url', library_sections.user_art_url as 'library_sections_user_art_url', library_sections.user_theme_music_url as 'library_sections_user_theme_music_url', library_sections.created_at as 'library_sections_created_at', library_sections.updated_at as 'library_sections_updated_at', library_sections.scanned_at as 'library_sections_scanned_at', library_sections.user_fields as 'library_sections_user_fields', library_sections.query_xml as 'library_sections_query_xml', library_sections.query_type as 'library_sections_query_type', library_sections.uuid as 'library_sections_uuid', library_sections.changed_at as 'library_sections_changed_at', library_sections.content_changed_at as 'library_sections_content_changed_at' from library_sections
****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: /root/Library/Application Support/Plex Media Server/Crash Reports/1.18.0.1944-f2cae8d6b/PLEX MEDIA SCANNER/72ea1c60-134d-eb5c-7477ca91-188061ac.dmp
Error in command line:the argument for option '--serverUuid' should follow immediately after the equal sign

The statement in question however works fine running manually in sqlite:

sqlite> select library_sections.id as 'library_sections_id', library_sections.library_id as 'library_sections_library_id', library_sections.name as 'library_sections_name', library_sections.name_sort as 'library_sections_name_sort', library_sections.section_type as 'library_sections_section_type', library_sections.language as 'library_sections_language', library_sections.agent as 'library_sections_agent', library_sections.scanner as 'library_sections_scanner', library_sections.user_thumb_url as 'library_sections_user_thumb_url', library_sections.user_art_url as 'library_sections_user_art_url', library_sections.user_theme_music_url as 'library_sections_user_theme_music_url', library_sections.created_at as 'library_sections_created_at', library_sections.updated_at as 'library_sections_updated_at', library_sections.scanned_at as 'library_sections_scanned_at', library_sections.user_fields as 'library_sections_user_fields', library_sections.query_xml as 'library_sections_query_xml', library_sections.query_type as 'library_sections_query_type', library_sections.uuid as 'library_sections_uuid', library_sections.changed_at as 'library_sections_changed_at', library_sections.content_changed_at as 'library_sections_content_changed_at' from library_sections;
1||Movies||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2018-11-22 02:13:05|2019-07-26 17:18:52|2019-10-17 23:35:43|pr%3AcollectionMode=1&pr%3AenableCinemaTrailers=0&pv%3AlastAddedAt=1555798380|||97cced92-9c96-4a38-b154-5c2a2ba2ea1a|2286939|0
2||TV Shows||2|en|com.plexapp.agents.thetvdb|Plex Series Scanner||||2018-11-22 02:14:10|2019-07-26 17:19:23|2019-10-17 23:35:48|pv%3AlastAddedAt=1555798380|||f454765f-6b28-4083-b912-ca25fa42b62e|2286995|0
4||Music||8|en|tv.plex.agents.music|Plex Music||||2018-12-31 08:17:06|2019-07-26 17:19:04|2019-10-17 23:35:44|pv%3AfirstLoudnessScan=0&pv%3AlastAddedAt=1555798380|||b4c6d553-c608-4cca-9edb-c92f3226fc61|2286960|0
6||Anime||2|en|com.plexapp.agents.thetvdb|Plex Series Scanner||||2019-04-06 16:03:03|2019-07-26 17:18:10|2019-10-17 23:35:40|pv%3AlastAddedAt=1555798380|||75581c50-2a46-4149-9609-cba98e3bdc84|2286886|0
7||B List Movies||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2019-04-13 03:52:34|2019-07-22 21:25:03|2019-10-17 23:35:41|pv%3AlastAddedAt=1555798380|||3c5e4194-397d-4c51-94dc-2df8a175c680|2089162|0
8||Anime Movies||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2019-05-07 10:29:12|2019-08-10 01:29:38|2019-10-17 23:35:41|pr%3AcollectionMode=1|||2875f37b-4c61-4925-8fd3-6f100a79b79e|2576030|0
9||Classical Movies||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2019-05-07 10:30:27|2019-07-22 21:24:53|2019-10-17 23:35:42||||531ad207-6d45-4e6e-882b-34736629a025|2089161|0
10||Soundtracks||8|en|tv.plex.agents.music|Plex Music||||2019-05-10 23:47:02|2019-07-26 17:19:10|2019-10-17 23:35:45|pv%3AfirstLoudnessScan=0|||3f75a5ec-f808-47b8-b7f3-16ab65d5ab76|2286970|3601920
12||Family Movies||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2019-05-22 12:48:24|2019-07-22 21:25:14|2019-10-17 23:35:43|pr%3AcollectionMode=1|||154cce01-60d8-4c0e-9ddc-3b1e7bcd2527|2089166|0
13||Audiobooks||8|en|tv.plex.agents.music|Plex Music||||2019-05-22 16:39:05|2019-07-26 17:18:22|2019-10-17 23:35:41|pv%3AfirstLoudnessScan=0|||74dacb42-af53-474f-9168-04cd78fe8fc1|2286928|0
14||MST3K and Rifftrax||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2019-05-22 21:31:22|2019-07-22 20:56:57|2019-10-17 23:35:44|pr%3AcollectionMode=1|||181a5844-7c58-48d7-8edf-341f27d502e8|2087944|0
15||Documentaries||1|en|com.plexapp.agents.imdb|Plex Movie Scanner||||2019-05-28 11:25:51|2019-07-22 21:24:36|2019-10-17 23:35:42||||f7d79e75-4d9f-4582-850c-a8a7d4c5c952|2089148|0
16||Docuserials||2|en|com.plexapp.agents.thetvdb|Plex Series Scanner||||2019-08-27 13:03:59|2019-08-27 13:03:59|2019-10-17 23:35:43||||b714ade9-a1e6-4c99-8d80-26034b1f4f24|2911795|0

And the server log (a bit truncated):

Oct 18, 2019 09:30:50.698 [0x7f696c0f9b80] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.26.0, threadsafe=1
Oct 18, 2019 09:30:50.739 [0x7f696c0f9b80] DEBUG - Running migrations. (EPG 0)
Oct 18, 2019 09:30:50.739 [0x7f696c0f9b80] DEBUG - Running forward migration 20180501000000.
Oct 18, 2019 09:30:50.739 [0x7f696c0f9b80] DEBUG - Captured session 0.
[repeat 19 times for sessions 1-19]
Oct 18, 2019 09:30:50.792 [0x7f696c0f9b80] DEBUG - Analyzing database.
Oct 18, 2019 09:30:50.965 [0x7f696c0f9b80] DEBUG - Vacuuming database.
Oct 18, 2019 09:30:52.390 [0x7f696c0f9b80] INFO - SQLITE3:(nil), 17, statement aborts at 57: [select * from metadata_items limit 1] database schema has changed
[repeat 18 times]
Oct 18, 2019 09:30:52.424 [0x7f696c0f9b80] DEBUG - Completed forward migration 20180501000000.
Oct 18, 2019 09:30:52.451 [0x7f696c0f9b80] DEBUG - ChangestampAllocator: initialized to 3610746
Oct 18, 2019 09:30:52.451 [0x7f696c0f9b80] DEBUG - Opening 2 database sessions to library (com.plexapp.plugins.library.blobs), SQLite 3.26.0, threadsafe=1
Oct 18, 2019 09:30:52.455 [0x7f696c0f9b80] DEBUG - Running migrations. (EPG 0)

This is the last place migrations are mentioned in the log.

Sort of at a loss here. I could rebuild the entire server structure by deleting the database, but that both deletes all the view history (which I would like to avoid) and doesn’t tell me why it happened or how to fix it in the future.

Any further ideas are appreciated.

I am facing the same issue.

Version: 1.18.2.2029-36236cc4c
OS: Ubuntu 18.04.3 LTS (via PPA)

@Deae-Lunae Were you able to get this fixed?

Seeing the same issue when adding a new library for movies. Seems to be an issue only for mp4 files, not for images or AVI/WMV/etc.

Nov 17, 2019 09:19:29.957 [18200] INFO - Plex Media Scanner v1.18.2.2029-36236cc4c - Microsoft PC x64 - build: windows-x86 - GMT -06:00
Nov 17, 2019 09:19:29.957 [18200] INFO - Windows version: 6.2 (Build 9200), language en-US
Nov 17, 2019 09:19:29.958 [18200] INFO - 8 2809 MHz processor(s): Architecture=0, Level=6, Revision=7685 Processor Identifier=Intel64 Family 6 Model 30 Stepping 5, GenuineIntel
Nov 17, 2019 09:19:29.958 [18200] DEBUG - “C:\Program Files (x86)\Plex\Plex Media Server\Plex Media Scanner.exe” --scan --refresh --section 7 --activity bc73f243-1a93-4d1a-8d0d-95e1a2332d73
Nov 17, 2019 09:19:29.955 [12412] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.26.0, threadsafe=1
Nov 17, 2019 09:19:30.217 [12412] ERROR - SQLITE3:0xeb1b8ef3, 1, no such column: library_sections.content_changed_at in "select library_sections.id as ‘library_sections_id’, library_sections.library_id as ‘library_sections_library_id’, library_sections.name as 'library_sect

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