How do I correct this plex database error? ERROR - [Req#31da63/Req#31da75] SQLITE3:0x80000001

Server Version#: 1.32.8.7639
Player Version#: 4.122.0

Server running Ubuntu 22.04.

I keep getting this database error. I have run Optimize Database and Clean Bundles on the troubleshooting menu. I have also run the DB Repair Tool from GitHub - ChuckPa/PlexDBRepair: Database repair utility for Plex Media Server databases

This keeps occurring and when it does sometimes the server seems to freeze for a few seconds.

ERROR - [Req#31da63/Req#31da75] SQLITE3:0x80000001, 1, no such column: grandchildren_settings.view_count in "select distinct metadata_items.id from metadata_items  left join metadata_item_settings on metadata_item_settings.guid=metadata_items.guid and metadata_item_settings.account_id= 1 where metadata_items.library_section_id in (6) and (grandchildren_settings.view_count>='1' and (select count(*) from metadata_items as leaves join metadata_items as parents on leaves.parent_id=parents.id left join metadata_item_settings on metadata_item_settings.guid = leaves.guid and metadata_item_settings.account_id=1 where (parents.parent_id=metadata_items.id or parents.id=metadata_items.id) and (metadata_item_settings.view_count=0 or metadata_item_settings.view_count is null) and leaves.metadata_type in (1, 4, 10))>=1 and (
Jan 24, 2024 13:14:40.944 [140589738711864] ERROR - [Req#31da63] Got exception from request handler: sqlite3_statement_backend::prepare: no such column: grandchildren_settings.view_count for SQL: select distinct metadata_items.id from metadata_items  left join metadata_item_settings on metadata_item_settings.guid=metadata_items.guid and metadata_item_settings.account_id= 1 where metadata_items.library_section_id in (6) and (grandchildren_settings.view_count>='1' and (select count(*) from metadata_items as leaves join metadata_items as parents on leaves.parent_id=parents.id left join metadata_item_settings on metadata_item_settings.guid = leaves.guid and metadata_item_settings.account_id=1 where (parents.parent_id=metadata_items.id or parents.id=metadata_items.id) and (metadata_item_settings.view_count=0 or metadata_item_settings.view_count is null) and leaves.metadata_type in (1, 4, 10))>=1 and (metadata_items.metadata_type=2 or metadata_items.metadata_type=10))  and metadata_items.metadata_type=2  and metadata_items.metadata_type=2 and length(metadata_items.user_thumb_url) > 0 order by random() limit 8

I’m okish working in a database so if there is a way to edit the database and fix this I can give it a try.

You’d have to export the table, add the column, edit the INSERT INTO statements, then reimport the SQL.

After that, you’d have to populate the column (which I don’t know how to do).

Which version did you upgrade from? (something old?)

Normal upgrade cycle auto through Plex. I’ve been having other problems with my box and my HD is just about full so I am purchased a new HD and going to start fresh with a new install once it gets delivered. Plex keeps crashing every night right around 9pm. Only that one time every day so I’m thinking of doing a clean install of Plex and see if my problem goes away. I’ve been trying to find the cause and for the life of me can’t figure it out. It’s very strange that it only does it once a day during that exact time frame.
I turned on debug logging today. If I post them tomorrow do you think you can take a look and see if it’s anything plex related? I suspect it’s something linux related that I haven’t been able to find.

@ehupp

Sorry for delay. I was out sick all week.

Yes, I’ll take a look.
Let me know when you’re ready and we’ll make arrangements for DB ZIP file exchange.

Sorry so long to reply. Hope you’re feeling better.

I ended up buying a new NUC to run Plex on and moved it over to that. Seems to be running well but I keep getting this error.

I noticed when I was importing my media that the screen was completly redrawing and flickering so bad it was basiclly unusable. I’m running an autoscan utility from GitHub - NiNiyas/autoscan: Fork of https://github.com/l3uddz/plex_autoscan with Jellyfin and Emby support. that pointed me in the direction of what was causing this. When I tried to import 2 items today I saw this in the logs.

I did copy over my Preferences file over from the old to the new computer.
When I saw this I ran a chmod -R user:user /var/lib/plexmediaserver/Library/Application Support/Plex Media Server.

I would bet it’s the file permissions for my Preferences.xml file.
I’ve tried looking online to see what my file permissions should be but not finding much.
If tha’ts not it I’m stumped.

-rw------- 1 plex plex 4486 Feb 22 12:14 Preferences.xml

I tried to go to the dump files listed and they don’t exist. So something isn’t writing correctly somewhere.

'****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Crash Reports/1.40.0.7998-c29d4c0c8/PLEX MEDIA SCANNER/791f92e1-178c-433e-45bf6d86-9321190d.dmp'
 2024-02-22 12:05:57,318 -     INFO -     UTILS [140541564335680]: 'Failed to load preferences at /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml'
 2024-02-22 12:05:57,320 -     INFO -     UTILS [140541564335680]: 'libc++abi: terminating with uncaught exception of type std::runtime_error: Empty or non-existant file.'
 2024-02-22 12:05:57,523 -     INFO -     UTILS [140541564335680]: 'Aborted (core dumped)'
 2024-02-22 12:05:57,524 -     INFO -      PLEX [140541564335680]: Finished basic analysis of metadata_item: '680922'.

  2024-02-22 12:38:47,153 -     INFO -     UTILS [139895876089408]: '****** PLEX MEDIA SCANNER CRASHED, CRASH REPORT WRITTEN: /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Crash Reports/1.40.0.7998-c29d4c0c8/PLEX MEDIA SCANNER/ca2fa59d-f4aa-443f-c1a0d2b5-488cdb51.dmp'
 2024-02-22 12:38:47,153 -     INFO -     UTILS [139895876089408]: 'Failed to load preferences at /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml'
 2024-02-22 12:38:47,153 -     INFO -     UTILS [139895876089408]: 'libc++abi: terminating with uncaught exception of type std::runtime_error: Empty or non-existant file.'
 2024-02-22 12:38:47,365 -     INFO -     UTILS [139895876089408]: 'Aborted (core dumped)'
 2024-02-22 12:38:47,365 -     INFO -      PLEX [139895876089408]: Finished basic analysis of metadata_item: '524201'.```

Tried to run the scanner manually from https://support.plex.tv/articles/201242707-plex-media-scanner-via-command-line/

root@Server-2:/usr/lib/plexmediaserver# ./'Plex Media Scanner' --list
libc++abi: terminating with uncaught exception of type soci::soci_error: 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.40.0.7998-c29d4c0c8/PLEX MEDIA SCANNER/f4d17bd6-84d8-4d9a-251389b2-c8e884d5.dmp

I also ran the db through your db repair tool.

No change.

Text from the dump log

Feb 23, 2024 09:38:16.994 [140074314140416] INFO - Plex Media Scanner v1.40.0.7998-c29d4c0c8 - unknown PC unknown - build: linux-x86_64 - GMT -08:00
Feb 23, 2024 09:38:16.994 [140074314140416] INFO - Linux version: 6.5.0-18-generic (#18~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 7 11:40:03 UTC 2), language: en-US
Feb 23, 2024 09:38:16.994 [140074314140416] INFO - Processor: 8-core 11th Gen Intel(R) Core™ i7-1165G7 @ 2.80GHz
Feb 23, 2024 09:38:16.994 [140074314140416] INFO - ./Plex Media Scanner --list
Feb 23, 2024 09:38:16.994 [140074354907968] DEBUG - Opening 20 database sessions to library (com.plexapp.plugins.library), SQLite 3.39.4, threadsafe=1
Feb 23, 2024 09:38:17.042 [140074354907968] ERROR - SQLITE3:0x80000001, 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_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 'libr

So somehow I am missing those sections from the db.

@ehupp

This is a case where the tables in the DB are missing.
The physical structure is fine but what PMS needs isn’t there.

This is where you use the REPLACE function to select one of your backup copies and make it the active DB

The problem I foresee with that is that when I started this whole thread I was having problems with my server crashing. I copied the database over to my new box. I would bet that the error was there in the old install and I just moved it to the new install. I just hadn’t run the manual scan test to identify it on the old box. So if I copy my old database over to this one I am probably going to be recreating an error that I copied over in the first part.

So I’m surmising that I either need to

  1. fix my database on this build.
  2. save my watch state and preferences and uninstall/reinstall
  3. copy over old database and hope it’s not broken like my new one.

I would prefer option 1 as I’ve had varying success at option 2.

Suggestions?

I can upload a copy of my database if you can take a look at it.

So I tried creating a whole new install. Installed from apt. Went through the wizard. With no libraries created I still get the same error. So this appears to be a problem with plex.

eric@Server-2:/usr/lib/plexmediaserver$ ./‘Plex Media Scanner’ --list
libc++abi: terminating with uncaught exception of type soci::soci_error: 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: /home/eric/Library/Application Support/Plex Media Server/Crash Reports/1.40.0.7998-c29d4c0c8/PLEX MEDIA SCANNER/20322012-3fe1-4491-8c800db2-9cfec095.dmp
Error in command line:the argument for option ‘–serverUuid’ should follow immediately after the equal sign
Crash Uploader options:

There are problems with the DB in 1.40.0.
Engineering has made changes and already looking at releasing in 1.40.1 / 1.40.2

For now, Back down to the highest 1.3x.x version you have

this was helpful, just for awareness I also had similar issues with my database at 1.40.0 and used this advice to drop back to my previous version after futilely trying a few things to repair the database after the update.

Ok, hopefully this will be fixed in an upcoming release.

Thanks for the info @ChuckPa

@ChuckPa Does this update correct the database error?

https://old.reddit.com/r/PleX/comments/1bevicy/new_public_pms_version_available_14018227c0dd5a73e/

I don’t know if 1.40.1 or 1.40.2. I don’t see specific info in the release notes.
We are testing 1.40.2 and 1.40.3 is hot on its heels.

1 Like

Just adding here that I have just installed Version 1.40.1.8227 and re-attempted to run “Plex Media Scanner” and still see the following:

“/usr/lib/plexmediaserver/Plex Media Scanner” --scan --refresh --force --section 6
Database exception: 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 where id=?

…so seems like we’re still waiting for 1.40.2. Do we know if this is something that can be fixed by running some SQLite commands, or is the issue with the code, not the schema?

Just got back from some travel and took a bunch of Docker updates including Plex. Didn’t even look at versions. Now I’m getting this in the docker’s WebUI:

Response code=“503” title=“Maintenance” status=“Plex Media Server is currently running database migrations.”

I have a 120TB library. Any ideas on how long I should wait to see if the migration is successful?

I would prefer not to nuke the Plex install and start over unless I absolutely have to. Also I don’t have the skills to easily handle the PlexDBRepair. I could learn, but I’ve never used that tool before.

It depends on how fast your server is. I have a 24-core threadripper, and mine still took an hour.

1 Like

upgrading to 1.40.x will take time because the database update.

“503” is a HTTP response.
There is NOTHING WRONG.
The server is telling you it’s updating.
Unfortunately, it doesn’t Auto-Refresh the page.
(Hit F5 / Control-F5 to force refresh periodically)

I have a 120TB array here (56 TB used plus about 275,000 QA test / dummy files). How many items do you have in PMS?

What does ‘top’ (not ‘htop’) show?
Is PMS still actively using a steady amount of CPU upgrading the DB?

As for using my repair tool, It’s menu driven and easily invoked in a terminal window

2 Likes

For those seeing the database exception when attempting to run Plex Media Scanner on the command line, be sure to define the PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR environment variable before executing the command. For example, this works on my system:

user@host:/usr/lib/plexmediaserver$ PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support"/ ./Plex\ Media\ Scanner --list

Make sure you set the variable appropriately for your installation, but the above is suitable for the default, native installation.

1 Like

To add to @pshanew

The environment variable is defined in the plexmediaserver.service file before launching PMS normally

1 Like