Plex Server DB errors Constant Crashing

Server Version#: 1.30.1.6562
Player Version#: 4.87.2
Unraid: 6.11.5
Docker Container: Plexinc/pms-docker:latest

My plex server started recently having some DB errors
Sqlite3: Sleeping for 200ms to retry busy DB.
We rebuild the DB but now this is what I’m getting. I’m a bit of a novice when it come to plex coding and such so please forgive my ignorance when it comes to the operation and handeling on here.

Any help would be appreciated.

Sqlite3: Sleeping for 200ms to retry busy DB.
libc++abi: terminating with uncaught exception of type soci::soci_error: sqlite3_statement_backend::prepare: near ")": syntax error for SQL: select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and )  order by metadata_items.title_sort
****** PLEX MEDIA SERVER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.30.1.6562-915986d62/PLEX MEDIA SERVER/7cf840cc-4dc4-478a-683ea689-839d446e.dmp
Stopping Plex Media Server.
Starting Plex Media Server.
Critical: libusb_init failed
libc++abi: terminating with uncaught exception of type soci::soci_error: sqlite3_statement_backend::prepare: near ")": syntax error for SQL: select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and )  order by metadata_items.title_sort
****** PLEX MEDIA SERVER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.30.1.6562-915986d62/PLEX MEDIA SERVER/2915c08a-7aeb-4bf4-858d2491-a1a13b83.dmp
Stopping Plex Media Server.
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Starting Plex Media Server.
Critical: libusb_init failed
Connection to 184.105.148.89 closed by remote host.
libc++abi: terminating with uncaught exception of type soci::soci_error: sqlite3_statement_backend::prepare: near ")": syntax error for SQL: select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and )  order by metadata_items.title_sort
****** PLEX MEDIA SERVER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.30.1.6562-915986d62/PLEX MEDIA SERVER/4e4287c6-db6b-4917-b4a0f692-b7885f9c.dmp
Stopping Plex Media Server.
Starting Plex Media Server.
Critical: libusb_init failed
Connection to 184.105.148.89 closed by remote host.
libc++abi: terminating with uncaught exception of type soci::soci_error: sqlite3_statement_backend::prepare: near ")": syntax error for SQL: select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and )  order by metadata_items.title_sort
****** PLEX MEDIA SERVER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.30.1.6562-915986d62/PLEX MEDIA SERVER/79712d4d-9c14-40bb-7c5f21b6-29c5c5e5.dmp
Stopping Plex Media Server.
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Starting Plex Media Server.
Critical: libusb_init failed
libc++abi: terminating with uncaught exception of type soci::soci_error: sqlite3_statement_backend::prepare: near ")": syntax error for SQL: select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and )  order by metadata_items.title_sort
****** PLEX MEDIA SERVER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.30.1.6562-915986d62/PLEX MEDIA SERVER/95f4cb8b-d598-417d-3069d883-3de6b2ce.dmp
Stopping Plex Media Server.
Starting Plex Media Server.
Critical: libusb_init failed
libc++abi: terminating with uncaught exception of type soci::soci_error: sqlite3_statement_backend::prepare: near ")": syntax error for SQL: select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and )  order by metadata_items.title_sort
****** PLEX MEDIA SERVER CRASHED, CRASH REPORT WRITTEN: /config/Library/Application Support/Plex Media Server/Crash Reports/1.30.1.6562-915986d62/PLEX MEDIA SERVER/c2e9f8ec-bc77-40ac-9f356295-300ba953.dmp
Stopping Plex Media Server.
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
Starting Plex Media Server.

Please supply a set of server logs that capture the crash. Someone versed in running Plex on Docker will be able to assist.

  1. Configure your server for debug, not verbose, level logging.
    Settings → Server_Name → General + Show Advanced

  2. Restart Plex Media Server

  3. After the next crash, restart Plex Media Server.

  4. Wait 3 to 5 minutes for Plex to fully boot and the logs to capture everything.

  5. Retrieve the log files, Settings → Troubleshooting.

  6. Upload the entire zip file to the thread.
    Drag it into the message window. It will attach at the cursor location.

Plex Media Server Logs_2023-01-10_20-27-06.zip (4.3 MB)

logs. Thank you!

Had another crash right after restart.

Would you like to try the DBRepair shell tool and see if it can ferret out bad records ?

I did run a repair on the db this is after the rebuild.

Plex Media Server Logs_2023-01-10_21-09-07.zip (3.2 MB)

Another set of logs after this latest crash.

This is a pretty new database and installation is there something I can be doing to help prevent these issues?

This DB is corrupt.

Jan 10, 2023 20:33:02.604 [0x14c8e42beb38] ERROR - SQLITE3:0x80000001, 1, near ")": syntax error in "select distinct metadata_items.id from metadata_items  where metadata_items.library_section_id in (1) and ((metadata_items.added_at>2147483647 and metadata_items.metadata_type=1) and

It’s failing on ‘distinct’. transactions aren’t completing.

Is the DB on the host or network / remote ?

Did you repair with my tool or Plex’s documented method?

It’s on the host.

As for repair I followed the steps in Spaceinvaderone’s YouTube video.

@Fallenfederation

Wow, that’s a really hard way to fix things. It assumes your backup database isn’t damaged. That’s risky.

Can I interest you in an easier way which will drop the corrupted records?

The important first part (which shows the README.md) is here.

The release is here.

How it works in docker.

  1. Place the script’s tar.gz / zip file wherever you have /config mapped.
  2. Start the container
  3. Enter the container (docker exec -it container_name bash)
  4. Shutdown Plex only (the container stays live) See README for instructions
  5. Extract the tool
  6. Now you can run the most common sequence (1 4 3 )
    – check and report status , should be OK
    – Repair (by export & import). This is where damaged records get dropped
    – Reindex (put the indexes, lost by repairing, back in before PMS starts)

Please see the readme and sample session at the bottom.

In actual use, When PMS crashes because of a database problem and this tool runs, PMS never crashed again. I hope it solves your problem too :crossed_fingers:

Don’t hesitate to ask any questions you might have,

Ok, I did use your tool and the DB had no detectable errors. I ran a repair and reindex on the DB with no affect. One thing I’m starting to notice is that the error happens a bunch when media is added to plex. Is there something that can cause it when adding media?

Plex Media Server Logs_2023-01-13_14-02-23.zip (2.2 MB)

Here are the logs after using the tool.

It seems the crash is happening when media is added. Anyone have any ideas why the DB would have problems when adding media only. The media is still added and processed by plex. After restart that takes about 8 to 10 seconds everything returns to normal operation.

THere are known issues with PMS crashing adding media.

The only known stable (IMHO) is 1.29.2

Recommend downgrading and waiting until it’s fixed.
Seems to be music / music analysis related (based on comments I’ve seen)

Ok I will try the downgrade. It’s easy with docker. Mine seems to be movies but I have not tried music yet. Thanks for the reply.

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