question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SQLite Error 19: 'FOREIGN KEY constraint failed'

See original GitHub issue

I recently installed embystat for the 1st time, using the latest linuxserver/embystat docker container, running 0.2.0-beta.37 It is connecting to a Jellyfin, also running in a docker container, currently version 10.8.1

There no issues with establishing the connection, but soon as I start syncing my movies or series, it fails at some point with the SQLite Error 19.

Especially when syncing the TV shows, it fails soon after starting and ends up only importing 1 series, continually failing at the same point.

[2022-06-30 12:13:47] []  [INF] --------------------------------------------------------------------
[2022-06-30 12:13:47] []  [INF] System info:
[2022-06-30 12:13:47] []  [INF] 	Environment	Production
[2022-06-30 12:13:47] []  [INF] 	Debugger	False
[2022-06-30 12:13:47] []  [INF] 	Process Name	EmbyStat
[2022-06-30 12:13:47] []  [INF] 	Version		0.2.0.0
[2022-06-30 12:13:47] []  [INF] 	Log level:	Information
[2022-06-30 12:13:47] []  [INF] 	Port:		6555
[2022-06-30 12:13:47] []  [INF] 	SSL Port:	6556
[2022-06-30 12:13:47] []  [INF] 	SSL Enabled:	False
[2022-06-30 12:13:47] []  [INF] 	URLs:		*
[2022-06-30 12:13:47] []  [INF] 	Config dir:	/config
[2022-06-30 12:13:47] []  [INF] 	Log dir:	/config/logs
[2022-06-30 12:13:47] []  [INF] 	Data dir:	/config
[2022-06-30 12:13:47] []  [INF] 	Can update:	False
[2022-06-30 12:13:47] []  [INF] 	As service:	False
[2022-06-30 12:13:47] []  [INF] --------------------------------------------------------------------
[2022-06-30 12:13:47] [Microsoft.Hosting.Lifetime]  [INF] Now listening on: http://[::]:6555
[2022-06-30 12:13:48] [EmbyStat.Core.DataStore.EsDbContext]  [INF] Found 1 pending database migration
[2022-06-30 12:13:48] [EmbyStat.Core.DataStore.EsDbContext]  [INF] Migrating database now, please hold on
[2022-06-30 12:13:49] [EmbyStat.Core.DataStore.EsDbContext]  [INF] Migrating DONE
[2022-06-30 12:13:50] [Microsoft.Hosting.Lifetime]  [INF] Application started. Press Ctrl+C to shut down.
[2022-06-30 12:13:50] [Microsoft.Hosting.Lifetime]  [INF] Hosting environment: Production
[2022-06-30 12:13:50] [Microsoft.Hosting.Lifetime]  [INF] Content root path: /opt/embystat
[2022-06-30 12:15:35] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] ---------------------------------
[2022-06-30 12:15:35] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Starting job
[2022-06-30 12:15:35] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] ---------------------------------
[2022-06-30 12:15:41] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Processing information from 33099 people
[2022-06-30 12:15:50] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Processing genres
[2022-06-30 12:15:50] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Processing shows
[2022-06-30 12:15:50] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] 1 libraries are selected, getting ready for processing
[2022-06-30 12:15:50] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Found 230 changed shows since last sync in TV Shows
[2022-06-30 12:15:50] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Fetching next block of 50 shows...
[2022-06-30 12:15:54] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Found 159 missing episodes for show Chicago Fire
[2022-06-30 12:15:57] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Found 0 missing episodes for show Surviving Jack
[2022-06-30 12:15:58] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [INF] Found 128 missing episodes for show Chicago P.D.
[2022-06-30 12:15:58] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [ERR] Error while running job
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.ExecuteNonQuery()
   at System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at Dapper.SqlMapper.ExecuteMultiImplAsync(IDbConnection cnn, CommandDefinition command, IEnumerable multiExec) in /_/Dapper/SqlMapper.Async.cs:line 624
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.ProcessShowBlock(Library library, IReadOnlyList`1 shows, IEnumerable`1 genres, Double increment)
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.ProcessChangedShows(Library library, IEnumerable`1 genres, Double logIncrementBase)
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.ProcessShowsAsync()
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
[2022-06-30 12:15:59] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [ERR] SQLite Error 19: 'FOREIGN KEY constraint failed'.
[2022-06-30 12:15:59] [EmbyStat.Jobs.Jobs.Sync.ShowSyncJob]  [ERR] Job failed, check logs for more info.
[2022-06-30 12:15:59] [Hangfire.AutomaticRetryAttribute]  [WRN] Failed to process the job 'eb176291-3d1b-4a98-8935-93985dd67f3f': an exception occurred. Retry attempt 1 of 2 will be performed in 00:00:17.
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.ExecuteNonQuery()
   at System.Data.Common.DbCommand.ExecuteNonQueryAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
   at Dapper.SqlMapper.ExecuteMultiImplAsync(IDbConnection cnn, CommandDefinition command, IEnumerable multiExec) in /_/Dapper/SqlMapper.Async.cs:line 624
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Core.Shows.ShowRepository.UpsertShows(IEnumerable`1 shows)
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.ProcessShowBlock(Library library, IReadOnlyList`1 shows, IEnumerable`1 genres, Double increment)
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.ProcessChangedShows(Library library, IEnumerable`1 genres, Double logIncrementBase)
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.ProcessShowsAsync()
   at EmbyStat.Jobs.Jobs.Sync.ShowSyncJob.RunJobAsync()
   at EmbyStat.Jobs.BaseJob.Execute()
   at EmbyStat.Jobs.BaseJob.Execute()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
andyforecommented, Dec 5, 2022

@mregni has there been anymore movement on this issue? New installation with version 0.2.0-beta.38 and I still seeing this error.

1reaction
mnejingcommented, Jan 19, 2023

I’m concerned this project is abandoned at this point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQLite EF Core - 'FOREIGN KEY constraint failed'
I fixed mine by declaring the foreign key as nullable in my POCO public ObjectTypeModel? TypeModel { get; set; } because it was...
Read more >
Can't see why: FOREIGN KEY constraint failed
This means that if the constraint is deferred there is a big difference between RESTRICT and NO ACTION.
Read more >
FOREIGN KEY constraint failed · Issue #16875 · dotnet/efcore
I get a Microsoft.Data.Sqlite.SqliteException: SQLite Error 19: 'FOREIGN KEY constraint failed'. If I remove the AddressId key, everythings fine ...
Read more >
sqlite error 19 'foreign key constraint failed #4691
I have two entities Entity1 and Entity2. When I'm running test case to create Entity1, It's giving me the below error. sqlite error...
Read more >
SQLite Error 19: 'FOREIGN KEY constraint failed'.
With that configuration I get: SqliteException: SQLite Error 19: 'FOREIGN KEY constraint failed'. Microsoft.Data.Sqlite.SqliteException.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found