# Plex Server DB errors Constant Crashing

**URL:** <https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362>\
**Category:** Plex Media Server\
**Tags:** server-linux, server-docker\
**Created:** [January 10, 2023, 10:57pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362 "2023-01-10T22:57:53Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 10, 2023, 10:57pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/1 "2023-01-10T22:57:53Z")

</div>

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.

```auto
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.

```

---

<div class="post-metadata">

**Author:** ![FordGuy61](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@FordGuy61](https://forums.plex.tv/u/FordGuy61)\
**Post date:** [January 10, 2023, 11:12pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/2 "2023-01-10T23:12:59Z")

</div>

Please supply a set of [server logs](https://support.plex.tv/articles/200250417-plex-media-server-log-files/) 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.

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 11, 2023, 3:28am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/3 "2023-01-11T03:28:05Z")

</div>

[Plex Media Server Logs\_2023-01-10\_20-27-06.zip](https://forums.plex.tv/uploads/short-url/aXQtMUh4Kybal4vooojc0cPczPZ.zip) (4.3 MB)

logs. Thank you!

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 11, 2023, 3:34am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/4 "2023-01-11T03:34:39Z")

</div>

Had another crash right after restart.

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [January 11, 2023, 3:49am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/5 "2023-01-11T03:49:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 11, 2023, 3:53am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/6 "2023-01-11T03:53:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 11, 2023, 4:10am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/7 "2023-01-11T04:10:43Z")

</div>

[Plex Media Server Logs\_2023-01-10\_21-09-07.zip](https://forums.plex.tv/uploads/short-url/y3pXIZ3wzrXb4pnizEJFbqtAsYV.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?

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [January 11, 2023, 5:03am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/8 "2023-01-11T05:03:41Z")

</div>

This DB is corrupt.

```auto
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 ?

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [January 11, 2023, 5:34am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/9 "2023-01-11T05:34:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 11, 2023, 7:07am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/10 "2023-01-11T07:07:06Z")

</div>

It’s on the host.

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

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [January 11, 2023, 7:59am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/12 "2023-01-11T07:59:28Z")

</div>

@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.

> **[GitHub - ChuckPa/PlexDBRepair: Database repair utility for Plex Media Server...](https://github.com/ChuckPa/PlexDBRepair)**
>
> Database repair utility for Plex Media Server databases - GitHub - ChuckPa/PlexDBRepair: Database repair utility for Plex Media Server databases

The release is here.

> **[Releases · ChuckPa/PlexDBRepair](https://github.com/ChuckPa/PlexDBRepair/releases)**
>
> Database repair utility for Plex Media Server databases - ChuckPa/PlexDBRepair

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 🤞

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

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 13, 2023, 8:30pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/14 "2023-01-13T20:30:53Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 13, 2023, 9:03pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/15 "2023-01-13T21:03:14Z")

</div>

[Plex Media Server Logs\_2023-01-13\_14-02-23.zip](https://forums.plex.tv/uploads/short-url/ob0jpD0oI7BFoFo9mWEMmHi6Wzj.zip) (2.2 MB)

Here are the logs after using the tool.

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 14, 2023, 11:03pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/16 "2023-01-14T23:03:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChuckPa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/chuckpa/32/79710_2.png) [@ChuckPa](https://forums.plex.tv/u/ChuckPa)\
**Post date:** [January 14, 2023, 11:46pm UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/17 "2023-01-14T23:46:22Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Fallenfederation](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/fallenfederation/32/17016_2.png) [@Fallenfederation](https://forums.plex.tv/u/Fallenfederation)\
**Post date:** [January 15, 2023, 2:14am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/18 "2023-01-15T02:14:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [April 15, 2023, 2:15am UTC](https://forums.plex.tv/t/plex-server-db-errors-constant-crashing/826362/19 "2023-04-15T02:15:13Z")

</div>

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