Server Version#: v.1.43.0.10231-ca3956848
Player Version#: NA/ALL
<If providing server logs please do NOT turn on verbose logging, only debug logging should be enabled>
System specs: Win11 Pro 24H2, i7-12700, 32GB DDR5, 2x 2TB M.2, 2.5GB wired ethernet
My Plex server has been crashing whenever I try a rescan of my TV folder, other libraries are scanning OK so I assume there is an episode or file in my TV folder that Plex is tripping up on.
Unfortunately I haven’t been able to find anything in the logs that pinpoints the exact bad file or files, I’m hoping the experts here can help me troubleshoot.
I updated my Plex server to the latest beta but that did not fix my issue, I was previously running the newest stable version.
My Plex server is a pre-build from Lenovo and it recently went through a warranty repair and all system components (RAM, CPU, disk) were QA checked and the machine passed all integrity checks by the Lenovo techs so I don’t think I have DB corruption from (example) a bad stick of RAM, etc.
I’m trying the suggestions I found in these forums, at this moment I am running a “PRAGMA integrity_check” against my DB. It’s a large DB file (just under 50GB) and since there’s no progress indicator I’m not 100% if the scan is hung or not. I do have DB backups going back about 2 months but I’d rather not restore from my backups because I just spent considerable time setting up some custom smart playlists and collections and I don’t want to lose that work.
I did not attach my log file(s) yet, but I am happy to provide that in a DM - just please let me know specifically which logfile to send, there are several.
I’m looking for 1st party solutions first. For the same reason I don’t want to post my logfiles in plain-text for all to see, I’m not in a hurry to feed my DB into some 3rd party app that’s going to be doing who-knows-what with my data.
The logfiles, the DB, there is P.I.I. - personally identifiable information contained within such as
my public WAN IP address,
my plex username,
my email address,
my windows username,
my Windows PC is domain-joined so also my domain name
very specific details of my computing environment : CPU with microcode version, OS
Maybe I’m paranoid but this is the world we live in.
I’m scrubbing one of my logfiles now to make sure I don’t have any info specific to me or my users or any login tokens, etc.
@ChuckPa is a staff member of Plex. Feel free to review the code at GitHub - ChuckPa/DBRepair: Database repair utility for Plex Media Server databases its one of the most useful tools for people who use Plex. I would recommend using it and see where it goes. If that doesn’t fix it. I would request a PM of your uncensored logs. (When users attempt to censor logs they remove needed info)
Just to be clear, are you referring to the single com.plexapp.plugins.library.db file; given your wording, I assume that’s the case. If so, that’s likely way, way too big. You may be affected by the database bloat problem that occurred over the summer. (I don’t have a link to the thread where it was discussed handy, but I’ll try to track it down.)
The issue caused massive database bloat (at least a couple of orders of magnitude above what it should be) and resulted in several issues, including database corruption.
Chuck’s utility is capable of correcting this bloat and checking for database corruption. While it is technically a 3rd-party project, it has been trusted by countless members of these forums. It’s also a script, so it’s not opaque (you have access to the source) and is run from the CLI.
[Edit]
I found the thread:
Note that it while it only describes a doubling of the database in the title, it was found to be much, much more severe as the thread grew.
My manual run of the PRAGMA integrity_check came back as ‘ok’ - I was going to run the other commands manually but reading through the script they’re all in there.
I’m on the first step (DB cleanup) and my best guesstimate has it at about 1/4 of the way completed if we can trust the I/O reporting in windows task mgr. This might take a few hours, will report back.
@pshanew yeah my com.plexapp.plugins.library.db is at 48.5GB, I agree it seems large. By comparison my DB in Kodi is under 600MB but it’s not a great 1:1 comparison because I have music and other items scanned into plex that I didn’t scan into Kodi.
@tjs4ever I must apologize I missed your comment about the database size. At almost 50GB something is definitely not right. I have a large collection and my file is comparatively massive vs most other users at 8.5GB Running Chuck’s script is 100% the method that should be followed to fix that.
ChuckPa, sorry for the ping, was trying to provide a link to your profile to establish your identity in relation to your repair script.
DBRepair 1.12.00 added the Deflate command. This is what removes the bloat.
It had been running as a free-standing script. Merging it into DBRepair gave it the full multi-host support it needed.
Deflate is a sequence of commands which must be performed in sequence without skipping any.
Given the amount of data being removed auto is strongly recommended AFTER deflate to put the DB in optimal order. (Deflate does a good job but final tweaks are always good while you’ve got the hood up )
I’m running the batfile version which has been going for just over 5 hours and is still on the first DB cleanup task. I’m OK to run a full-auto twice for it to have a second-pass at optimization but I hope the version I’m running will perform the needed tasks in the right order.
There’s also a zipped download in the windows section of that github which contains the ps1, the bat and a readme but that version is even older at v1.00.00.
I’m ok with the command line with either a ps1 or the cli of SQLite
Should I kill this batfile, is it safe to do so?
You know windows better than I (not used it in 20 years)
I did just ask GROK to convert my script to Window bat file format.
Please review
I always operate on the TMPDIR copy of the DB. I only overwrite the original after all operations complete without error. DBRepair makes that ‘backup’ copy in the tmpdir to keep it isolated.
Grok referred to sqlite3.exe. Obviously ,PlexSQLite.exe is needed.
There are two steps but this is the main worker. This is the one which slugs through the DB, record by record to see what needs to be deleted.
(On my i9 machine, 35 GB took about 12 minutes to slug through.. single threaded)
This is pass 1 (cleaning). Pass 2 (vacuuming into a new DB) is next.
@echo off
setlocal
rem --- Replace these with your actual paths/values ---
set "SQLITE=C:\path\to\sqlite3.exe"
set "DBPATH=%TMPDIR%\%CPPL%.db-BACKUP-%TimeStamp%
rem ----------------------------------------------------
(
echo BEGIN IMMEDIATE;
echo.
echo CREATE TABLE temp_bandwidth (
echo id INTEGER PRIMARY KEY,
echo account_id INTEGER,
echo device_id INTEGER,
echo timespan INTEGER,
echo at INTEGER,
echo lan INTEGER,
echo bytes INTEGER
echo );
echo.
echo INSERT INTO temp_bandwidth (
echo account_id, device_id, timespan, at, lan, bytes
echo )
echo SELECT account_id, device_id, timespan, at, COALESCE(lan, 0), bytes
echo FROM statistics_bandwidth WHERE account_id IS NOT NULL;
echo.
echo DROP TABLE statistics_bandwidth;
echo ALTER TABLE temp_bandwidth RENAME TO statistics_bandwidth;
echo.
echo CREATE INDEX IF NOT EXISTS index_statistics_bandwidth_on_at
echo ON statistics_bandwidth(at);
echo.
echo CREATE INDEX IF NOT EXISTS index_statistics_bandwidth_on_account_id_and_timespan_and_at
echo ON statistics_bandwidth(account_id, timespan, at);
echo.
echo COMMIT;
) | "%SQLITE%" "%DBPATH%"
endlocal
@echo off
setlocal
rem === CONFIGURATION (Replace with actual values or set externally) ===
set "SQLITE=C:\path\to\Plex_sqlite3.exe"
set "TMPDIR=%TEMP%"
set "CPPL=com.plexapp.plugins.library"
set "TimeStamp=%DATE:~-4%%DATE:~4,2%%DATE:~7,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%"
set "TimeStamp=%TimeStamp: =0%" :: Fix leading space in hour
rem Build paths
set "DBPATH=%TMPDIR%\%CPPL%.db-BACKUP-%TimeStamp%"
set "DEFLATEPATH=%TMPDIR%\%CPPL%.db-DEFLATE-%TimeStamp%"
rem === EXECUTE VACUUM INTO ===
"%SQLITE%" "%DBPATH%" "VACUUM main INTO '%DEFLATEPATH%'"
if %ERRORLEVEL% equ 0 (
echo VACUUM INTO succeeded: %DEFLATEPATH%
) else (
echo ERROR: VACUUM INTO failed with code %ERRORLEVEL%
exit /b %ERRORLEVEL%
)
endlocal
So, at the risk of sounding ungrateful - which I honestly do appreciate your help, especially at this late hour.
I’m not super keen on proof-reading and being a beta tester for an AI-converted script. Last I checked plex was a company with paid support staff and developers. Having to go through a forum and rely on volunteers is just… not optimal. With community driven projects like kodi, sonarr and the like - I understand that a forum post is the only option.
Maybe I’m just nostalgic for the days where you had an issue, opened a ticket and then someone was assigned to your case.
That being said, could I send my bloated/inflated DB to plex to have a pro fix it with the latest-greatest tools? I could FTP my DB or host it on a gDrive.
@ChuckPa I zipped my DB down to 2.32GB if that alleviates any concerns about sending 50GB files back-and-forth. I wasn’t able to send you a DM but maybe if you direct message me I can reply.