Jellyfin Forum
SOLVED: Database Lock prevents new media from being scanned in - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+---- Forum: Media Scanning & Identification (https://forum.jellyfin.org/f-media-scanning-identification)
+---- Thread: SOLVED: Database Lock prevents new media from being scanned in (/t-solved-database-lock-prevents-new-media-from-being-scanned-in)



Database Lock prevents new media from being scanned in - Ellermw - 2025-12-19

The logs show constant database is locked errors.  Because of this a lot of new media just isn't being picked up.  I end up having to use Claude to force the database to add these pieces of media otherwise it locks up and doesn't add in new content.

Should I change it from NoLock to Pessimistic?  I remember during that during one of the 10.11.X betas.

I'm currently on 10.11.5, running in linux (ubuntu 22.04 LTS).


RE: Database Lock prevents new media from being scanned in - Ellermw - 2025-12-19

Ok so Pessimistic wasn't the move. It then causes query congestion, meaning if a library scan is in process, it locks/blocks UI queries... so you can't even load Jellyfin's home page.

Some of the errors from the logs when it was set to NoLock

Bash(journalctl -u jellyfin --since "2 minutes ago" 2>/dev/null | tail -30)
⎿ Dec 19 21:12:43 LXCJellyfin jellyfin[833181]: Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: UserDat
a.ItemId, UserData.UserId, UserData.CustomDataKey'.
Dec 19 21:12:43 LXCJellyfin jellyfin[833181]: at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()

Going to try Optimistic now instead of Pessimistic for the DB Locking behavior

Also like to note that I have my parallel tasks limited to 2 for both.


RE: Database Lock prevents new media from being scanned in - Ellermw - 2025-12-19

I've also started to notice that Jellyfin is also not removing entries from the database for pieces of media that are no longer there. Along with it doesn't discover new series.

**Ignore this. I can't delete this comment. It seems it is, kinda of. I see several FFMEG probe errors for tv show episodes I no longer have, but they still exist in the db. So I don't know


RE: Database Lock prevents new media from being scanned in - Ellermw - 2025-12-19

Bug report generated by Claude:

Bug Report: Library scan not discovering new symlinked folders

Jellyfin Version: 10.11.5

Environment:
- Ubuntu 22.04.5 LTS
- x64 architecture
- SQLite database with Optimistic locking
- Media stored on network storage (Ceph), accessed via symlinks on local ext4 filesystem

Problem Description:

Library scans are not discovering new symlinked folders. The scan only refreshes existing database entries but does not enumerate the filesystem to find new content.

Timeline:
- Last successfully added series: November 27, 2025
- 95+ symlinks created after this date exist on disk but are NOT in the database
- All scans since then have failed to discover these new folders

What I've verified:
- All symlinks are valid and accessible
- The jellyfin user has read permissions to all symlinks and their targets
- sudo -u jellyfin ls "/path/to/symlinked/folder/" works correctly
- inotify limits are sufficient (max_user_watches: 4194304)
- Library configuration is correct with single path entry
- EnableRealtimeMonitor is true

Reproduction steps:
1. Have a TV library pointing to a directory containing symlinks to network storage
2. Create new symlinks in that directory
3. Run a library scan
4. New symlinks are not discovered or added to the database

Additional observation:

When I manually insert database entries for the missing symlinked series using SQL, Jellyfin removes them during the "Validating media library" phase at startup. The log shows:

[INF] Validating media library
[INF] Removing item, Type: Series, Name: [Series Name], Path: /path/to/symlink, Id: [uuid]

This suggests the validation code also cannot "see" the symlinks, even though they are valid and readable.

Expected behavior:
Library scan should enumerate all folders (including symlinks) in the library path and add new ones to the database.

Actual behavior:
Library scan only iterates over existing database entries. New symlinked folders are never discovered, and manually-added entries are removed during validation.

Logs showing the issue:

During scan, I see "Running enqueue of items in library [Library Name]" but no new series are added. The scan proceeds to refresh existing items only.

At startup, "Validating media library" removes entries for valid symlinks:
[INF] Stopping directory watching for path /media/TV
[INF] Validating media library
[INF] Removing item, Type: Series, Name: [Show1], Path: /media/TV/[Show1]
[INF] Removing item, Type: Series, Name: [Show2], Path: /media/TV/[Show2]
...

Workarounds attempted:
- Creating a new library pointing to the same path - shares same folder entry, doesn't help
- Multiple server restarts
- Multiple library scans
- Manual SQL insertion (entries get removed by validation)


RE: Database Lock prevents new media from being scanned in - Ellermw - 2025-12-20

I believe I fixed this. It appears the DateCreated field for the folder entry for a library media path was empty, possibly from a past migration. By fixing this field, it fixed it's ability to detect and add new media.