Jellyfin Forum
SOLVED: Database disk image is Malformed - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+--- Thread: SOLVED: Database disk image is Malformed (/t-solved-database-disk-image-is-malformed)

Pages: 1 2


Database disk image is Malformed - sneakie - 2025-03-22

Hello!

Summary of issue:
My server ends up in a state where the scheduled task to "Scan Media Library" ends up failing over and over again, the server tends to run just fine and nothing seemingly is going wrong with the server, but the task just cant complete.

Quick info:
Jellyfin is run on an unraid server, consisting of 5x HDDs via docker.

Unraid version: 6.12.6
Jellyfin version: 10.10.6

Things I've tried/thought of:
I backup the jellyfin folder on intervals and I just remake it from that backup anytime the error comes up and it disappears but always comes back.

As I was making this thread I realized disk1 "only" has 423gb out of 16tb available and I wonder if that might be the reason the database malformed? (When I searched the forum that was one of the most common questions asked)
 
Logs:
https://privatebin.net/?38aa391d58363bcf#6hALzKmjp3QPkmxEJZigyBPACcp6BM9XBzzLSSdNJ5Vk

Im pretty new to this, so if I provided the wrong logs please point me in a direction to figure out how to get the ones needed. (also is there some kind of "anonymize" logs addon/website/setting?)

Basically what I'm wondering is if there is some kind of permanent fix for this or if its just randomly corrupted itself.

Thanks in advance.


RE: Database disk image is Malformed - TheDreadPirate - 2025-03-22

What plugins do you have installed? And what file system is the jellyfin app data and database located on?


RE: Database disk image is Malformed - sneakie - 2025-03-22

Filesystem: XFS
current active plugins:
aniDB, AniList, AudioDB, Merge Versions, Musicbrainz, OMDb, Open Subtitles, Studio Images, TMDb and TheTVDB.

*quick edit*

Assuming the DB is in the Jellyfin folders with the appdata, they are both on an XFS filesystem and turns out they are not on disk1 as I first thought
they are actually on a completely separate nvme SSD that has 397/500gb available on it.


RE: Database disk image is Malformed - theguymadmax - 2025-03-22

Take a look at this post and see if it helps: https://forum.jellyfin.org/t-solved-malformed-jellyfin-database?pid=54778#pid54778


RE: Database disk image is Malformed - sneakie - 2025-03-22

This might be a bit of a beginner question, but how do I run the script in this context?

I mean the "#!/bin/bash
cat <( sqlite3 "$1" .dump | grep "^ROLLBACK" -v ) <( echo "COMMIT;" ) | sqlite3 "fix_$1""

I got the sqlite3 commandline utility tool for windows on my main computer, but couldnt figure out how to run the command. Might be a bit slow on the uptake.

Sorry!


RE: Database disk image is Malformed - TheDreadPirate - 2025-03-23

That command is for Linux. I don't know powershell so I can't convert it to a Windows equivalent command.

Looking at the stackoverflow link, I think you should be able to run the following commands in Windows.

Code:
cd $DATABASE_LOCATION
echo '.dump'|sqlite3 $DB_NAME|sqlite3 repaired_$DB_NAME
mv $DB_NAME corrupt_$DB_NAME
mv repaired_$DB_NAME $DB_NAME

Replace everything with a $ before the word with the indicated file name.


RE: Database disk image is Malformed - sneakie - 2025-03-23

E:\yaddayadda\yaddayadda2>echo '.dump'|sqlite3 library.db|sqlite3 repaired_library.db
Parse error near line 1: near "'.dump'": syntax error
'.dump'
^--- error here

It keeps throwing me this error, so it doesnt work. (for some reason)

I tried to manually dump the database inside sqlite3 into a new one, but the problem with that is that the new .db never gets filled, it either stays as 0kb or is half the size and when running an integritycheck on this new "db" it says its not a db.


RE: Database disk image is Malformed - sneakie - 2025-03-23

Sorry.

Ive not slept yet so I was a little slow and missed the word "shell" and was using cmd.

Using powershell I managed to executed "PS E:\*****\databasefolder> echo '.dump'|sqlite3 library.db|sqlite3 repaired_library.db"

this created repaired_library.db, which is 0KB, so similar result I managed to get while trying to dump it in sqlite3.


RE: Database disk image is Malformed - sneakie - 2025-03-23

Ok. So I managed to create a new DB that resembles the real deal (206000 KB vs 200000 KB) which also passes the pragma integrity check, which leads me to believe it might have worked, though I cant be sure, because I don't think the integrity check is meant to see if a database is healthy, just to check for errors?

What I did was I changed '.dump' to '.recover' in the powershell command.

Just for some more information in case this isn't a solution or anyone comes across this:

When checking both Library.db & Jellyfin.db with pragma integrity check; they both produced these errors:

Jellyfin.db: row 34 missing from index IX_ActivityLogs_DateCreated
Library.db: *** in database main ***, Tree 7 page 39598 cell 37: Rowid 232781 out of order, database disk image is malformed

and after running powershell command above with the alterations, both appear to be error free.


RE: Database disk image is Malformed - TheDreadPirate - 2025-03-23

(2025-03-23, 02:15 AM)sneakie Wrote: Ok. So I managed to create a new DB that resembles the real deal (206000 KB vs 200000 KB) which also passes the pragma integrity check, which leads me to believe it might have worked, though I cant be sure, because I don't think the integrity check is meant to see if a database is healthy, just to check for errors?

What I did was I changed '.dump' to '.recover' in the powershell command.

Just for some more information in case this isn't a solution or anyone comes across this:

When checking both Library.db & Jellyfin.db with pragma integrity check; they both produced these errors:

Jellyfin.db: row 34 missing from index IX_ActivityLogs_DateCreated
Library.db: *** in database main ***, Tree 7 page 39598 cell 37: Rowid 232781 out of order, database disk image is malformed

and after running powershell command above with the alterations, both appear to be error free.

The Jellyfin startup afterwards without all the database malformed messages?