Eight Different Bosses, One SQLite Database: Fixing Overnight Plex Crashes

If you have ever seen Office Space, you probably remember Peter Gibbons explaining that he has eight different bosses all yelling at him about TPS reports. For a few months, that was pretty much what my Plex server was dealing with every single night between midnight and 7:00 AM. I would wake up, grab my coffee, try to put something on, and find Plex completely locked up and waiting for a manual container restart.

At first, I assumed it was just a random glitch or a bad update. Once it kept happening during the overnight maintenance window, I finally dug into the logs across Plex, Kometa, and Maintainerr to see who was actually breaking things. Turns out, nobody was innocent, and everything was stepping on each other’s toes at the exact same time.

The Stack

Before diving into the logs, here is what was running on my TrueNAS box in Docker:

  • Plex Media Server (v1.43.2 and later v1.43.5)
  • Kometa for metadata, overlays, and collection management
  • Maintainerr for automated library cleanup rules and “leaving soon” collections
  • Tdarr for background AV1 re-encoding
  • Radarr, Sonarr, and Lidarr to organize content (plus a stale Bazarr webhook I forgot to clean up)

Individually, each of these containers solves a real shortcoming in Plex. Put them all on overlapping overnight schedules, and things start to fall apart.

What Was Actually Breaking

When you run multiple automated services against Plex at the same time, Plex can get mad and lock up. This happens because Plex uses an embedded SQLite database (com.plexapp.plugins.library.db) to track everything in your library. SQLite is fast and reliable for normal playback, but it locks the database during write operations, which means every other write job has to sit in line and wait.

My overnight window was spread loosely across nine hours (22:00 to 07:03), even though all of the jobs combined only needed about an hour and a half of active runtime. Here is what was colliding in that window:

  • Plex Scheduled Maintenance (Butler): Plex was running heavy database maintenance (VACUUM operations and long-running queries taking 18 to 20 minutes each) right in the middle of other tools hitting the API.
  • Kometa API bursts: Unthrottled metadata updates were hammering Plex. During a Nov 3 hang that required a manual restart at 07:37, the logs showed a flood of requests from the Kometa container right before Plex stopped responding.
  • Maintainerr rule and overlay runs: Maintainerr was evaluating rules, calling emptyTrash, and processing poster overlays while Plex was still trying to finish its own maintenance.
  • Tdarr and a stale Bazarr webhook: Background AV1 encoding and leftover webhook calls added extra library churn on top of everything else.

On top of the database lock contention, the logs also caught a separate background loop. Plex’s MusicAnalysis (LoudnessJobManager) service was hitting corrupted or audio-less music tracks and retrying them roughly every two minutes. One single track (metadata ID 1066145) showed up 1,599 times in the logs with Error decoding analysis input files (exit code: 234) and Track has no audio stream. errors.

How the Timeline Played Out

Fixing this took a few rounds of trial and error as I peeled back each layer:

  1. June 2026: I first traced the instability to SQLite lock contention across Butler, Tdarr, Kometa, and Maintainerr. I added sleep_time throttling to Kometa, removed the stale Bazarr webhook, and started spacing out the maintenance windows.
  2. October 2026: I loosened Maintainerr’s “Movies Leaving” rules because stale media was sticking around indefinitely, which grew the collection to around 3,442 items. I also traced unusually long Maintainerr rule runtimes to TMDB metadata year drift.
  3. November 3, 2026: Plex (v1.43.5) hung overnight again and needed a manual restart around 07:37. Tracing the timestamps back pointed straight to a burst of Kometa requests right before the hang.
  4. November 12, 2026: I pulled the full Maintainerr (maintainerr-2026-11-12.log) and Kometa (meta-1.log, meta-2.log) logs to measure exact runtimes. Maintainerr only used 32m 26s of active time across a five-hour window, and Kometa’s two runs took 38m 46s and 12m 22s, yet Maintainerr’s 05:02 cleanup left less than an hour before Kometa’s 06:00 collection run.

Using AI to Untangle the Logs

Reading through Plex, Kometa, and Maintainerr logs by hand is pure information overload. When you have three or four different containers writing thousands of lines across separate files, it is easy to miss how a task in one container lines up with a slowdown in another.

Handing those raw log files to AI tools made a huge difference here. Instead of scrolling through endless timestamps, I could drop in the Maintainerr, Kometa, and Plex log bundles and ask for exact task durations, error counts, and cross-service correlations. That is how I caught that Maintainerr was only doing 32 minutes of real work inside a five-hour window, that track 1066145 had failed 1,599 times, and that Kometa’s requests lined up right before Plex locked up.

You still have to stay in the driver’s seat and verify what the tool finds against your actual setup, since it does not know your container constraints on its own. For parsing messy log files and connecting the dots across different services, though, it saved me hours of manual grep work.

Rebuilding the Overnight Schedule

Once I had the real runtimes in front of me, the fix was straightforward. Instead of letting everything fire whenever it felt like it, I packed the entire pipeline into a strict sequential order starting at 02:00, when nobody is streaming. I also scheduled Tdarr to stop at 02:00 and start back up at 07:00 because it is configured to notify Plex whenever an encode finishes, and I do not want it hitting the database during maintenance.

There are two scheduling constraints you have to work around here. First, Plex Butler and Kometa can only be scheduled on the hour, while Maintainerr cron jobs can run at any minute. Second, you want Plex Butler to run last so it can vacuum and clean up the database after Maintainerr deletes media and Kometa rebuilds collections.

Here is the final schedule alongside the actual runtimes I verified in the Nov 13 logs:

Scheduled TimeService / TaskObserved Runtime (Nov 13)Buffer Before NextPurpose
02:00Tdarr (Pause Encoding)Scheduled stop—Stops encoding so finished jobs don’t notify Plex during maintenance
02:00Kometa (Operations / Seasonal)02:00:20 to 02:35:08 (34m 48s)24m 52sLibrary ops and seasonal checks (on the hour)
03:00Maintainerr Rules (Main)03:00:00 to 03:08:43 (8m 43s)6m 17sEvaluates main leaving rules
03:15Maintainerr Rules (Seasonal)03:15:00 to 03:18:34 (3m 34s)11m 26sEvaluates four seasonal movie rule groups
03:30Maintainerr Collection Worker03:30:00 to 03:30:39 (39s)29m 21sDeletes due media (removed 22 movies)
04:00Kometa (Collections)04:00:12 to 04:14:18 (14m 05s)5m 42sUpdates collections post-cleanup (on the hour)
04:20Maintainerr Rule Maintenance04:20:00 to 04:20:12 (12s)9m 48sInternal rule maintenance
04:30Maintainerr Overlay Processor04:30:00 to 04:48:27 (18m 27s)11m 33sApplies poster overlays (286 applied)
05:00 - 07:00Plex Scheduled Maintenance (Butler)05:00 to 07:00 (2h window)NoneRuns last to clean up and vacuum
07:00Tdarr (Resume Encoding)Scheduled start—Resumes AV1 encoding once Plex Butler finishes

When I checked the Plex, Kometa, and Maintainerr logs after the first run under this schedule on Nov 13, every single job finished inside its slot with zero overlaps and zero database is locked errors across the entire 02:00 to 07:30 window. Even Plex’s two longest Butler queries wrapped up at 05:06:51 (19m 48s) and 05:24:47 (18m 08s), leaving over an hour of breathing room before 07:00.

Stopping the Music Analysis Loop

To stop LoudnessJobManager from hammering the server every two minutes while I track down the bad audio files, I turned off audio analysis globally in Plex:

  1. Open the Plex Web App and go to Settings > [Your Server Name] > Library.
  2. Set Analyze audio tracks for loudness to Never.
  3. Set Analyze audio tracks for sonic features to Never.
  4. Click Save Changes, then restart your Plex Docker container so any already-queued jobs are cleared.

Heads up: Recent Plex builds can still spawn LoudnessJobManager tasks if you only disable these toggles at the per-library level, so changing the global server settings is the safest route until your audio files are cleaned up.

Since the Plex logs only printed metadata ID 1066145 without a file path, you can use Plex’s built-in Plex SQLite tool in read-only mode inside your Plex container to find the exact file and scan for any other music tracks missing an audio stream (stream_type = 2). Always back up your database or stick strictly to -readonly when querying.

# Identify track 1066145 and its file path
"/usr/lib/plexmediaserver/Plex SQLite" -readonly \
  "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" \
  "SELECT mi.id, mi.title, alb.title AS album, art.title AS artist, mp.file
   FROM metadata_items mi
   JOIN metadata_items alb ON mi.parent_id = alb.id
   JOIN metadata_items art ON alb.parent_id = art.id
   JOIN media_items m ON m.metadata_item_id = mi.id
   JOIN media_parts mp ON mp.media_item_id = m.id
   WHERE mi.id = 1066145;"

# List all music tracks missing an audio stream
"/usr/lib/plexmediaserver/Plex SQLite" -readonly \
  "/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db" \
  "SELECT mi.id, mi.title, mp.file
   FROM metadata_items mi
   JOIN media_items m ON m.metadata_item_id = mi.id
   JOIN media_parts mp ON mp.media_item_id = m.id
   LEFT JOIN media_streams ms ON ms.media_item_id = m.id AND ms.stream_type = 2
   WHERE mi.metadata_type = 10 AND ms.id IS NULL;"
Code language: Bash (bash)

Shifting from a loose nine-hour free-for-all to a tight five-hour sequential pipeline completely eliminated my overnight Plex crashes without sacrificing any automation. If your Plex container keeps locking up while you are asleep, grab the timestamps from your helper containers first, line everything up in order, and make sure Plex Butler runs last.

Published on

by

Nick

Leave a Comment