mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-04 18:09:12 +03:00
SQLite Error 19: 'UNIQUE constraint failed #7845
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lukasjanra30 on GitHub (Nov 28, 2025).
Description of the bug
I wanted to remove one series which Ive done watching but after doing it I found out my library no more refreshes. Then I found out issue is with that remove series. I readded it and now everything works. When I remove it again, there are again issues. Im using Podman with autoupdate image latest
Reproduction steps
I dont really know, Im doing deletion of some series normally. Only this is causing issue.
What is the current bug behavior?
I wanted to remove one series which Ive done watching but after doing it I found out my library no more refreshes. Then I found out issue is with that remove series. I readded it and now everything works. When I remove it again, there are again issues. Im using Podman with autoupdate image latest
What is the expected correct behavior?
To be able to remove what I want without breaking library refresh
Jellyfin Server version
10.11.3
Specify commit id
No response
Specify unstable release number
No response
Specify version number
No response
Specify the build version
10.11.3
Environment
Jellyfin logs
FFmpeg logs
Client / Browser logs
No response
Relevant screenshots or videos
No response
Additional information
No response
@RrOoSsSsOo commented on GitHub (Dec 1, 2025):
With this bug, the media library can "only grow".
The real problem is that the error occurs before the newly found titles are added...
@RrOoSsSsOo commented on GitHub (Dec 1, 2025):
But shouldn't such a debilitating bug be included among those to be fixed as 0-day? With the utmost attention from as many developers as possible.
@QuentinJones commented on GitHub (Dec 2, 2025):
Having the same issue with my library but not sure what started it. I had renamed a bunch of files which got removed from the library, but this is breaking now before it can add the new ones. When I'm refreshing meta data with the scan for new files option now I get this error and the process fails prematurely.
2025-12-02 10:49:12.703 | [10:49:12] [INF] [7] Emby.Server.Implementations.Library.LibraryManager: Removing item, Type: Folder, Name: Smile 2022 BluRay 1080p DTS AC3 x264-MgB, Path: /media/video/Movies/<redacted>, Id: f69791d9-f141-fc20-024e-85eaf2206262 2025-12-02 10:49:12.768 | [10:49:12] [ERR] [7] Microsoft.EntityFrameworkCore.Database.Command: Failed executing DbCommand (5ms) [Parameters=[@__date_1='?' (DbType = DateTime), @__p_0='?' (Size = 469)], CommandType='Text', CommandTimeout='30'] 2025-12-02 10:49:12.768 | UPDATE "UserData" AS "u" 2025-12-02 10:49:12.768 | SET "ItemId" = '00000000-0000-0000-0000-000000000001', 2025-12-02 10:49:12.768 | "RetentionDate" = @__date_1 2025-12-02 10:49:12.768 | WHERE "u"."ItemId" IN ( 2025-12-02 10:49:12.768 | SELECT "p"."value" 2025-12-02 10:49:12.768 | FROM json_each(@__p_0) AS "p" 2025-12-02 10:49:12.768 | ) 2025-12-02 10:49:12.803 | [10:49:12] [ERR] [7] Microsoft.EntityFrameworkCore.Query: An exception occurred while executing an 'ExecuteUpdate' operation for context type 'Jellyfin.Database.Implementations.JellyfinDbContext'. 2025-12-02 10:49:12.803 | Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: UserData.ItemId, UserData.UserId, UserData.CustomDataKey'. 2025-12-02 10:49:12.803 | at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() 2025-12-02 10:49:12.803 | at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) 2025-12-02 10:49:12.803 | at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) 2025-12-02 10:49:12.803 | at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.<>c.<NonQueryResult>b__31_0(DbContext _, ValueTuple3 state)2025-12-02 10:49:12.803 | at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.NonQueryResult(RelationalQueryContext relationalQueryContext, RelationalCommandResolver relationalCommandResolver, Type contextType, CommandSource commandSource, Boolean threadSafetyChecksEnabled)
2025-12-02 10:49:12.803 | Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: UserData.ItemId, UserData.UserId, UserData.CustomDataKey'.
2025-12-02 10:49:12.803 | at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
2025-12-02 10:49:12.803 | at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
2025-12-02 10:49:12.803 | at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject)
2025-12-02 10:49:12.803 | at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.<>c.b__31_0(DbContext _, ValueTuple
3 state) 2025-12-02 10:49:12.803 | at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.NonQueryResult(RelationalQueryContext relationalQueryContext, RelationalCommandResolver relationalCommandResolver, Type contextType, CommandSource commandSource, Boolean threadSafetyChecksEnabled) 2025-12-02 10:49:12.806 | [10:49:12] [ERR] [7] MediaBrowser.Providers.Manager.ProviderManager: Error refreshing item 2025-12-02 10:49:12.806 | Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'UNIQUE constraint failed: UserData.ItemId, UserData.UserId, UserData.CustomDataKey'. 2025-12-02 10:49:12.806 | at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() 2025-12-02 10:49:12.806 | at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) 2025-12-02 10:49:12.806 | at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQuery(RelationalCommandParameterObject parameterObject) 2025-12-02 10:49:12.806 | at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.<>c.<NonQueryResult>b__31_0(DbContext _, ValueTuple3 state)2025-12-02 10:49:12.806 | at Microsoft.EntityFrameworkCore.Query.RelationalShapedQueryCompilingExpressionVisitor.NonQueryResult(RelationalQueryContext relationalQueryContext, RelationalCommandResolver relationalCommandResolver, Type contextType, CommandSource commandSource, Boolean threadSafetyChecksEnabled)
2025-12-02 10:49:12.806 | at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteCore[TResult](Expression query, Boolean async, CancellationToken cancellationToken)
2025-12-02 10:49:12.806 | at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
2025-12-02 10:49:12.806 | at Jellyfin.Server.Implementations.Item.BaseItemRepository.DeleteItem(IReadOnlyList
1 ids) 2025-12-02 10:49:12.806 | at Emby.Server.Implementations.Library.LibraryManager.DeleteItem(BaseItem item, DeleteOptions options, BaseItem parent, Boolean notifyParentItem) 2025-12-02 10:49:12.806 | at MediaBrowser.Controller.Entities.Folder.ValidateChildrenInternal2(IProgress1 progress, Boolean recursive, Boolean refreshChildMetadata, Boolean allowRemoveRoot, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService, CancellationToken cancellationToken)2025-12-02 10:49:12.806 | at MediaBrowser.Controller.Entities.Folder.ValidateChildrenInternal(IProgress
1 progress, Boolean recursive, Boolean refreshChildMetadata, Boolean allowRemoveRoot, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService, CancellationToken cancellationToken) 2025-12-02 10:49:12.806 | at MediaBrowser.Providers.Manager.ProviderManager.RefreshCollectionFolderChildren(MetadataRefreshOptions options, CollectionFolder collectionFolder, CancellationToken cancellationToken) 2025-12-02 10:49:12.806 | at MediaBrowser.Providers.Manager.ProviderManager.RefreshItem(BaseItem item, MetadataRefreshOptions options, CancellationToken cancellationToken) 2025-12-02 10:49:12.806 | at MediaBrowser.Providers.Manager.ProviderManager.StartProcessingRefreshQueue()@RrOoSsSsOo commented on GitHub (Dec 3, 2025):
To reproduce the error:
[≤ v10.11.4]
@v3DJG6GL commented on GitHub (Dec 5, 2025):
I have the same error with the series that caused the issues described in https://github.com/jellyfin/jellyfin/issues/15628
Setup:
Jellyfin Server version
10.11.4
Specify the build version
10.11.4
Environment
Description of the bug
When I scanned the library again (Scan for new and updated files), I received the following error messages (see below for complete logs):
The series was now displayed twice: once at the old, no longer existing path and once at the new location.
Now the new location has been deleted correctly, but the old one still appears when I search for the series.
Notes:
Jellyfin was usable again after enabling all Disable User Data options from plugin Disable User Data: Also searching for series Valeria/showing Media Info for individual episodes worked again.
Jellyfin logs
@v3DJG6GL commented on GitHub (Dec 5, 2025):
Update: I extracted the affected DB entries from jellyfin.db:
Valeria.csv
After deleting these entries, I could manually delete the series from within Jellyfin.
Re-adding and moving the series to another library directory also seems to work now: New location gets recognized, old location gets deleted from Jellyfin :)
However, issue https://github.com/jellyfin/jellyfin/issues/15628 still persists: Transcoding is causing complete crash/lockup of Jellyfin after some minutes... (but that is a separate issue I suppose)
@jpSimkins commented on GitHub (Dec 12, 2025):
I am having the same issue.
I was able to work around this by re-creating the folder that was missing for the series that was causing the issue. This allows scans to work again and for new content to still be processed.
After recreating the folder and having the scan run successfully, I am then able to delete the series as expected. No clue why this happens but this is how I got around it. This is not a permissions issue for my case.
@attilatdeak commented on GitHub (Jan 2, 2026):
Got the same again.
Im on 10.11.5 at the moment. Removing a series result in:
[2026-01-02 04:20:40.146 +01:00] [INF] Removing item, Type: "Series", Name: "The Daily Life of the Immortal King", Path: "/mnt/18TBEXOS/ANIME/The.Daily.Life.of.the.Immortal.King.(2020).[tmdb-98123]", Id: 0f415f23-701f-9dad-63db-2a30ac2889eb [2026-01-02 04:20:40.264 +01:00] [ERR] Failed executing DbCommand ("0"ms) [Parameters=["@__date_1='?' (DbType = DateTime), @__p_0='?' (Size = 7996)"], CommandType='Text', CommandTimeout='30']" ""UPDATE \"UserData\" AS \"u\" SET \"ItemId\" = '00000000-0000-0000-0000-000000000001', \"RetentionDate\" = @__date_1 WHERE \"u\".\"ItemId\" IN ( SELECT \"p\".\"value\" FROM json_each(@__p_0) AS \"p\" )"SET "ItemId" = '00000000-0000-0000-0000-000000000001',
Id: 0f415f23-701f-9dad-63db-2a30ac2889eb
so its trying to update the userdata table, where the series itemid is with... set itemid to a hardcoded 0001 id? They wanna set to mark it if the series is still on the server, i believe, but they are setting the wrong column?
if you simply delete any row containing the ID from the UserData table, the issue is solved and the server can dump the rest of the relevant data from database without an issue.
@shikanime commented on GitHub (Jan 8, 2026):
As a workaround, assuming you don't care about the user data, I deleted the user to which the user data was related, so I could delete the shows, then re-create the user.
@Drun555 commented on GitHub (Jan 9, 2026):
My library scan also fails with next output:
Tried to manually delete all records from UserData with ItemID = '00000000-0000-0000-0000-000000000001' (without success, of course). I do have a quite big library with several users, so I am considering a wipe only as a last resort.
@attilatdeak commented on GitHub (Jan 9, 2026):
The row before these entries contains the failing ID.
@Drun555 commented on GitHub (Jan 9, 2026):
Ah, just noticed that. Tried to shut it down / delete these records, but without luck - error just appears again after restart with the same ID.
@LinFor commented on GitHub (Jan 12, 2026):
I have the same issue:
@solarflair commented on GitHub (Jan 18, 2026):
I'm also experiencing the same thing. Not going to post the logs unless someone specifically asks because they're no different from what has already been shared, with the same errors just with different filenames. I've tried removing the media named in the error with no effect. It's no longer updating the problem library with newly added material, presumably because of whatever is causing this.
@Drun555 commented on GitHub (Jan 18, 2026):
I ended up deleting everything from UserDatas. Better than non-working library at least.
(also tried upgrading to the latest nightly, but it didn’t resolved anything)
@steamkittens commented on GitHub (Jan 25, 2026):
Same issue as https://github.com/jellyfin/jellyfin/issues/15343