Upgrade from 10.5 to 10.6 fails on MigrateUserDatabase with "SQLite Error 19: 'FOREIGN KEY constraint failed" #2042

Closed
opened 2025-12-21 20:02:20 +01:00 by backuprepo · 11 comments
Owner

Originally created by @adamcik on GitHub (Aug 14, 2020).

Originally assigned to: @barronpm on GitHub.

Describe the bug

Jellyfin does not start up after upgrading to 10.6, it is crash looping trying to apply the MigrateUserDatabase step which fails with SQLite Error 19: 'FOREIGN KEY constraint failed.

I've tried skimming over https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs, but since I'm not familiar with your code or database schema's it's not obvious where the error is actually being triggered and if I can workaround it (other than wiping all the databases and starting clean).

I would be happy to poke at my sqlite databases if that would help debugging.

System (please complete the following information):

  • OS: Debian 10
  • Virtualization: KVM
  • Clients: Browser, Android, Chromecast
  • Browser: Chrome 84.0.4147.105
  • Jellyfin Version: 10.6.2
  • Playback: n/a
  • Installed Plugins: Open subtitles
  • Reverse Proxy: nginx
  • Base URL: none
  • Networking: Bridge/NAT
  • Storage: NFS

To Reproduce

  1. Perform debian upgrade from 10.5.5-1 to 10.6.2-1
  2. Startup fails on MigrateUserDatabase with SQLite Error 19: 'FOREIGN KEY constraint failed'.

Expected behavior

Migration completes and system starts up.

Logs

[2020-08-13 04:03:49.069 +02:00] [INF] Jellyfin version: "10.6.2"
[2020-08-13 04:03:49.089 +02:00] [INF] Environment Variables: ["[JELLYFIN_WEB_OPT, --webdir=/usr/share/jellyfin/web]", "[JELLYFIN_RESTART_OPT, --restartpath=/usr/lib/jellyfin/restart.sh]", "[JELLYFIN_USER, jellyfin]", "[JELLYFIN_LOG_DIR, /var/log/jellyfin]", "[JELLYFIN_CACHE_DIR, /var/cache/jellyfin]", "[JELLYFIN_ARGS, $JELLYFIN_WEB_OPT $JELLYFIN_RESTART_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT]", "[JELLYFIN_DATA_DIR, /var/lib/jellyfin]", "[JELLYFIN_CONFIG_DIR, /etc/jellyfin]", "[JELLYFIN_FFMPEG_OPT, --ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg]"]
[2020-08-13 04:03:49.102 +02:00] [INF] Arguments: ["/usr/lib/jellyfin/bin/jellyfin.dll", "--webdir=/usr/share/jellyfin/web", "--restartpath=/usr/lib/jellyfin/restart.sh", "--ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg", ""]
[2020-08-13 04:03:49.102 +02:00] [INF] Operating system: "Linux"
[2020-08-13 04:03:49.102 +02:00] [INF] Architecture: X64
[2020-08-13 04:03:49.103 +02:00] [INF] 64-Bit Process: True
[2020-08-13 04:03:49.103 +02:00] [INF] User Interactive: True
[2020-08-13 04:03:49.103 +02:00] [INF] Processor count: 1
[2020-08-13 04:03:49.103 +02:00] [INF] Program data path: "/var/lib/jellyfin"
[2020-08-13 04:03:49.103 +02:00] [INF] Web resources path: "/usr/share/jellyfin/web"
[2020-08-13 04:03:49.104 +02:00] [INF] Application directory: "/usr/lib/jellyfin/bin/"
[2020-08-13 04:03:49.217 +02:00] [INF] Setting cache path: "/var/cache/jellyfin"
[2020-08-13 04:03:49.223 +02:00] [INF] Loading assemblies
[2020-08-13 04:03:49.229 +02:00] [INF] Loaded assembly "OpenSubtitlesHandler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" from "/var/lib/jellyfin/plugins/Open Subtitles/OpenSubtitlesHandler.dll"
[2020-08-13 04:03:49.231 +02:00] [INF] Loaded assembly "Jellyfin.Plugin.OpenSubtitles, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null" from "/var/lib/jellyfin/plugins/Open Subtitles/Jellyfin.Plugin.OpenSubtitles.dll"
[2020-08-13 04:03:57.223 +02:00] [INF] Applying migration '"MigrateUserDatabase"'
[2020-08-13 04:03:57.227 +02:00] [INF] Migrating the user database may take a while, do not stop Jellyfin.
[2020-08-13 04:03:57.456 +02:00] [ERR] Could not apply migration '"MigrateUserDatabase"'
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
 ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
   --- End of inner exception stack trace ---
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
   at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
   at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform()
   at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory)
[2020-08-13 04:03:57.461 +02:00] [FTL] Error while starting server.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
 ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
   at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.ExecuteReader()
   at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
   --- End of inner exception stack trace ---
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
   at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
   at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform()
   at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory)
   at Jellyfin.Server.Program.StartApp(StartupOptions options)
[2020-08-13 04:03:57.464 +02:00] [INF] Disposing "CoreAppHost"
[2020-08-13 04:03:57.464 +02:00] [INF] Disposing "ActivityLogWebSocketListener"
[2020-08-13 04:03:57.466 +02:00] [INF] Disposing "SessionInfoWebSocketListener"
[2020-08-13 04:03:57.467 +02:00] [INF] Disposing "ScheduledTasksWebSocketListener"
[2020-08-13 04:03:57.468 +02:00] [INF] Disposing "SessionWebSocketListener"
[2020-08-13 04:03:57.469 +02:00] [INF] Disposing "EmbyTV"
[2020-08-13 04:03:57.470 +02:00] [INF] Received a SIGTERM signal, shutting down

Screenshots

Additional context

This system previously had an Emby install before switching to Jellyfin, I assume there was some auto import / conversion of the databases from it, but I never actively did anything beyond using apt to install jellyfin. So I'm not sure if I started clean at some point and forgot or if this is a converted database.

Originally created by @adamcik on GitHub (Aug 14, 2020). Originally assigned to: @barronpm on GitHub. **Describe the bug** <!-- A clear and concise description of what the bug is. --> Jellyfin does not start up after upgrading to 10.6, it is crash looping trying to apply the `MigrateUserDatabase` step which fails with `SQLite Error 19: 'FOREIGN KEY constraint failed`. I've tried skimming over https://github.com/jellyfin/jellyfin/blob/master/Jellyfin.Server/Migrations/Routines/MigrateUserDb.cs, but since I'm not familiar with your code or database schema's it's not obvious where the error is actually being triggered and if I can workaround it (other than wiping all the databases and starting clean). I would be happy to poke at my sqlite databases if that would help debugging. **System (please complete the following information):** - OS: Debian 10 - Virtualization: KVM - Clients: Browser, Android, Chromecast - Browser: Chrome 84.0.4147.105 - Jellyfin Version: 10.6.2 - Playback: n/a - Installed Plugins: Open subtitles - Reverse Proxy: nginx - Base URL: none - Networking: Bridge/NAT - Storage: NFS **To Reproduce** <!-- Steps to reproduce the behavior: --> 1. Perform debian upgrade from 10.5.5-1 to 10.6.2-1 1. Startup fails on `MigrateUserDatabase` with `SQLite Error 19: 'FOREIGN KEY constraint failed'.` **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> Migration completes and system starts up. **Logs** <!-- Please paste any log errors. --> ``` [2020-08-13 04:03:49.069 +02:00] [INF] Jellyfin version: "10.6.2" [2020-08-13 04:03:49.089 +02:00] [INF] Environment Variables: ["[JELLYFIN_WEB_OPT, --webdir=/usr/share/jellyfin/web]", "[JELLYFIN_RESTART_OPT, --restartpath=/usr/lib/jellyfin/restart.sh]", "[JELLYFIN_USER, jellyfin]", "[JELLYFIN_LOG_DIR, /var/log/jellyfin]", "[JELLYFIN_CACHE_DIR, /var/cache/jellyfin]", "[JELLYFIN_ARGS, $JELLYFIN_WEB_OPT $JELLYFIN_RESTART_OPT $JELLYFIN_FFMPEG_OPT $JELLYFIN_SERVICE_OPT $JELLYFIN_NOWEBAPP_OPT]", "[JELLYFIN_DATA_DIR, /var/lib/jellyfin]", "[JELLYFIN_CONFIG_DIR, /etc/jellyfin]", "[JELLYFIN_FFMPEG_OPT, --ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg]"] [2020-08-13 04:03:49.102 +02:00] [INF] Arguments: ["/usr/lib/jellyfin/bin/jellyfin.dll", "--webdir=/usr/share/jellyfin/web", "--restartpath=/usr/lib/jellyfin/restart.sh", "--ffmpeg=/usr/lib/jellyfin-ffmpeg/ffmpeg", ""] [2020-08-13 04:03:49.102 +02:00] [INF] Operating system: "Linux" [2020-08-13 04:03:49.102 +02:00] [INF] Architecture: X64 [2020-08-13 04:03:49.103 +02:00] [INF] 64-Bit Process: True [2020-08-13 04:03:49.103 +02:00] [INF] User Interactive: True [2020-08-13 04:03:49.103 +02:00] [INF] Processor count: 1 [2020-08-13 04:03:49.103 +02:00] [INF] Program data path: "/var/lib/jellyfin" [2020-08-13 04:03:49.103 +02:00] [INF] Web resources path: "/usr/share/jellyfin/web" [2020-08-13 04:03:49.104 +02:00] [INF] Application directory: "/usr/lib/jellyfin/bin/" [2020-08-13 04:03:49.217 +02:00] [INF] Setting cache path: "/var/cache/jellyfin" [2020-08-13 04:03:49.223 +02:00] [INF] Loading assemblies [2020-08-13 04:03:49.229 +02:00] [INF] Loaded assembly "OpenSubtitlesHandler, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null" from "/var/lib/jellyfin/plugins/Open Subtitles/OpenSubtitlesHandler.dll" [2020-08-13 04:03:49.231 +02:00] [INF] Loaded assembly "Jellyfin.Plugin.OpenSubtitles, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null" from "/var/lib/jellyfin/plugins/Open Subtitles/Jellyfin.Plugin.OpenSubtitles.dll" [2020-08-13 04:03:57.223 +02:00] [INF] Applying migration '"MigrateUserDatabase"' [2020-08-13 04:03:57.227 +02:00] [INF] Migrating the user database may take a while, do not stop Jellyfin. [2020-08-13 04:03:57.456 +02:00] [ERR] Could not apply migration '"MigrateUserDatabase"' Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform() at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory) [2020-08-13 04:03:57.461 +02:00] [FTL] Error while starting server. Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(CommandBehavior behavior) at System.Data.Common.DbCommand.ExecuteReader() at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform() at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory) at Jellyfin.Server.Program.StartApp(StartupOptions options) [2020-08-13 04:03:57.464 +02:00] [INF] Disposing "CoreAppHost" [2020-08-13 04:03:57.464 +02:00] [INF] Disposing "ActivityLogWebSocketListener" [2020-08-13 04:03:57.466 +02:00] [INF] Disposing "SessionInfoWebSocketListener" [2020-08-13 04:03:57.467 +02:00] [INF] Disposing "ScheduledTasksWebSocketListener" [2020-08-13 04:03:57.468 +02:00] [INF] Disposing "SessionWebSocketListener" [2020-08-13 04:03:57.469 +02:00] [INF] Disposing "EmbyTV" [2020-08-13 04:03:57.470 +02:00] [INF] Received a SIGTERM signal, shutting down ``` **Screenshots** <!-- If applicable, add screenshots to help explain your problem. --> **Additional context** <!-- Add any other context about the problem here. --> This system previously had an Emby install before switching to Jellyfin, I **assume** there was some auto import / conversion of the databases from it, but I never actively did anything beyond using apt to install jellyfin. So I'm not sure if I started clean at some point and forgot or if this is a converted database.
backuprepo 2025-12-21 20:02:20 +01:00
Author
Owner

@adamcik commented on GitHub (Aug 14, 2020):

One a side note, I'm not able to downgrade (assuming that would even be safe to do) as it seems the apt repository doesn't provide 10.5 packages any more. It would be nice if the repo could keep the last couple of versions around so people can mitigate by rolling back if something breaks.

@adamcik commented on GitHub (Aug 14, 2020): One a side note, I'm not able to downgrade (assuming that would even be safe to do) as it seems the apt repository doesn't provide 10.5 packages any more. It would be nice if the repo could keep the last couple of versions around so people can mitigate by rolling back if something breaks.
Author
Owner

@PrplHaz4 commented on GitHub (Aug 14, 2020):

One a side note, I'm not able to downgrade (assuming that would even be safe to do) as it seems the apt repository doesn't provide 10.5 packages any more. It would be nice if the repo could keep the last couple of versions around so people can mitigate by rolling back if something breaks.

Since there were db schema changes during this upgrade, rolling back is not as simple as just getting the old binaries.

If you took a backup of the db, this might help you downgrade: https://github.com/jellyfin/jellyfin-docs/pull/372/files

@PrplHaz4 commented on GitHub (Aug 14, 2020): > > > One a side note, I'm not able to downgrade (assuming that would even be safe to do) as it seems the apt repository doesn't provide 10.5 packages any more. It would be nice if the repo could keep the last couple of versions around so people can mitigate by rolling back if something breaks. Since there were db schema changes during this upgrade, rolling back is not as simple as just getting the old binaries. If you took a backup of the db, this might help you downgrade: https://github.com/jellyfin/jellyfin-docs/pull/372/files
Author
Owner

@adamcik commented on GitHub (Aug 14, 2020):

Sadly I didn't backup before upgrading, and since this is "just" a VM for jellyfin I never setup any more persistent backup scheme. But thanks for the pointer. I'll leave things in the state they are or at least make a backup before wiping things clean in case it helps the investigation. Loosing the state for what we've watched isn't the end of the world :-)

@adamcik commented on GitHub (Aug 14, 2020): Sadly I didn't backup before upgrading, and since this is "just" a VM for jellyfin I never setup any more persistent backup scheme. But thanks for the pointer. I'll leave things in the state they are or at least make a backup before wiping things clean in case it helps the investigation. Loosing the state for what we've watched isn't the end of the world :-)
Author
Owner

@adamcik commented on GitHub (Oct 11, 2020):

I've tried debugging, but ended up giving up on this and have purged all the jellyfin data to start fresh :( As such I can't really help reproduce this any longer. So feel free to close this issue if that makes sense.

@adamcik commented on GitHub (Oct 11, 2020): I've tried debugging, but ended up giving up on this and have purged all the jellyfin data to start fresh :( As such I can't really help reproduce this any longer. So feel free to close this issue if that makes sense.
Author
Owner

@gerroon commented on GitHub (Dec 12, 2020):

These sql schema changes constantly breaking existing databases and upgrades have been a recurring theme. It would be nice if the devs are more careful about this. Iso far wiped my Jellyfin database at least 3 times already.

@gerroon commented on GitHub (Dec 12, 2020): These sql schema changes constantly breaking existing databases and upgrades have been a recurring theme. It would be nice if the devs are more careful about this. Iso far wiped my Jellyfin database at least 3 times already.
Author
Owner

@cvium commented on GitHub (Apr 9, 2021):

Since this is a data issue we really need access to a database that exhibits this.

@cvium commented on GitHub (Apr 9, 2021): Since this is a data issue we really need access to a database that exhibits this.
Author
Owner

@wouterla commented on GitHub (Jun 16, 2021):

I'm having this same issue, I think.
I will attach the users.db file, since I'll have to change the passwords anyway.

This is the log:

[23:22:12] [INF] [1] Jellyfin.Server.Migrations.MigrationRunner: Applying migration 'MigrateUserDatabase'
[23:22:12] [INF] [1] Jellyfin.Server.Migrations.Routines.MigrateUserDb: Migrating the user database may take a while, do not stop Jellyfin.
[23:22:14] [ERR] [1] Jellyfin.Server.Migrations.MigrationRunner: Could not apply migration 'MigrateUserDatabase'
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform()
at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory)
[23:22:14] [FTL] [1] Main: Error while starting server.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection)
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)
at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform()
at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory)
at Jellyfin.Server.Program.StartApp(StartupOptions options)
[23:22:14] [INF] [1] Emby.Server.Implementations.ApplicationHost: Disposing CoreAppHost
[23:22:14] [INF] [1] Emby.Server.Implementations.ApplicationHost: Disposing EmbyTV
[23:22:14] [INF] [2] Main: Received a SIGTERM signal, shutting down

users.db.gz

@wouterla commented on GitHub (Jun 16, 2021): I'm having this same issue, I think. I will attach the users.db file, since I'll have to change the passwords anyway. This is the log: ```[23:22:12] [INF] [1] Jellyfin.Server.Migrations.MigrationRunner: Migration 'AddDefaultPluginRepository' applied successfully [23:22:12] [INF] [1] Jellyfin.Server.Migrations.MigrationRunner: Applying migration 'MigrateUserDatabase' [23:22:12] [INF] [1] Jellyfin.Server.Migrations.Routines.MigrateUserDb: Migrating the user database may take a while, do not stop Jellyfin. [23:22:14] [ERR] [1] Jellyfin.Server.Migrations.MigrationRunner: Could not apply migration 'MigrateUserDatabase' Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform() at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory) [23:22:14] [FTL] [1] Main: Error while starting server. Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'. at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db) at Microsoft.Data.Sqlite.SqliteDataReader.NextResult() at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.Execute(IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.Execute(IEnumerable`1 commandBatches, IRelationalConnection connection) at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.SaveChanges(IList`1 entries) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(IList`1 entriesToSave) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(DbContext _, Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.Storage.NonRetryingExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded) at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChanges(Boolean acceptAllChangesOnSuccess) at Microsoft.EntityFrameworkCore.DbContext.SaveChanges(Boolean acceptAllChangesOnSuccess) at Jellyfin.Server.Migrations.Routines.MigrateUserDb.Perform() at Jellyfin.Server.Migrations.MigrationRunner.Run(CoreAppHost host, ILoggerFactory loggerFactory) at Jellyfin.Server.Program.StartApp(StartupOptions options) [23:22:14] [INF] [1] Emby.Server.Implementations.ApplicationHost: Disposing CoreAppHost [23:22:14] [INF] [1] Emby.Server.Implementations.ApplicationHost: Disposing EmbyTV [23:22:14] [INF] [2] Main: Received a SIGTERM signal, shutting down ``` [users.db.gz](https://github.com/jellyfin/jellyfin/files/6665954/users.db.gz)
Author
Owner

@ShadwDrgn commented on GitHub (Sep 1, 2022):

has anyone figured this out at all because my jellyfin instance is now down because i tried to upgrade and it's completely broken restarting over and over trying to migrate and crashing :( going from 10.7 to 10.8

@ShadwDrgn commented on GitHub (Sep 1, 2022): has anyone figured this out at all because my jellyfin instance is now down because i tried to upgrade and it's completely broken restarting over and over trying to migrate and crashing :( going from 10.7 to 10.8
Author
Owner

@knuxbbs commented on GitHub (Apr 23, 2023):

has anyone figured this out at all because my jellyfin instance is now down because i tried to upgrade and it's completely broken restarting over and over trying to migrate and crashing :( going from 10.7 to 10.8

Same here.

@knuxbbs commented on GitHub (Apr 23, 2023): > has anyone figured this out at all because my jellyfin instance is now down because i tried to upgrade and it's completely broken restarting over and over trying to migrate and crashing :( going from 10.7 to 10.8 Same here.
Author
Owner

@barronpm commented on GitHub (Apr 24, 2023):

has anyone figured this out at all because my jellyfin instance is now down because i tried to upgrade and it's completely broken restarting over and over trying to migrate and crashing :( going from 10.7 to 10.8

So in your logs, MigrateUserDatabase is the one that fails? This migration shouldn't even be running unless you are updating from 10.5 or earlier. What does your migrations.xml look like?

@barronpm commented on GitHub (Apr 24, 2023): > has anyone figured this out at all because my jellyfin instance is now down because i tried to upgrade and it's completely broken restarting over and over trying to migrate and crashing :( going from 10.7 to 10.8 So in your logs, `MigrateUserDatabase` is the one that fails? This migration shouldn't even be running unless you are updating from 10.5 or earlier. What does your migrations.xml look like?
Author
Owner

@sevenrats commented on GitHub (Oct 5, 2023):

both of these server versions are eol.

@sevenrats commented on GitHub (Oct 5, 2023): both of these server versions are eol.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: starred/jellyfin#2042
No description provided.