Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FOREIGN KEY constraint failed - Saving Person #3440

Open
Fmstrat opened this issue Dec 6, 2024 · 2 comments
Open

FOREIGN KEY constraint failed - Saving Person #3440

Fmstrat opened this issue Dec 6, 2024 · 2 comments
Labels
help wanted Extra attention is needed needs-triage Needs to be triaged by a developer and assigned a release

Comments

@Fmstrat
Copy link

Fmstrat commented Dec 6, 2024

What happened?

This seems to be unique from the other constraint issues logged as solved in the past, as it has to do with "people":

|books-kavita  | 2024-12-06T14:37:00.837668388Z [Kavita] [2024-12-06 09:37:00.837 -05:00  48] [Error] Microsoft.EntityFrameworkCore.Database.Command Failed executing DbCommand (0ms) [Parameters=[@p0='3884', @p1='5395', @p2='3'], CommandType='"Text"', CommandTimeout='30']
|books-kavita  | 2024-12-06T14:37:00.837725659Z INSERT INTO "ChapterPeople" ("ChapterId", "PersonId", "Role")
|books-kavita  | 2024-12-06T14:37:00.837743748Z VALUES (@p0, @p1, @p2);
|books-kavita  | 2024-12-06T14:37:00.839296216Z [Kavita] [2024-12-06 09:37:00.838 -05:00  48] [Error] Microsoft.EntityFrameworkCore.Update An exception occurred in the database while saving changes for context type 'API.Data.DataContext'.
|books-kavita  | 2024-12-06T14:37:00.839335328Z Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
|books-kavita  | 2024-12-06T14:37:00.839350065Z  ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
|books-kavita  | 2024-12-06T14:37:00.839365850Z    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
|books-kavita  | 2024-12-06T14:37:00.839381076Z    at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
|books-kavita  | 2024-12-06T14:37:00.839395463Z    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
|books-kavita  | 2024-12-06T14:37:00.839410200Z    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839440232Z    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839460347Z    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839479833Z    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839498342Z    --- End of inner exception stack trace ---
|books-kavita  | 2024-12-06T14:37:00.839516641Z    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839535987Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839583480Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839605760Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839627342Z    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839646479Z    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839667292Z    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839686429Z Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
|books-kavita  | 2024-12-06T14:37:00.839705566Z  ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
|books-kavita  | 2024-12-06T14:37:00.839724982Z    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
|books-kavita  | 2024-12-06T14:37:00.839744259Z    at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
|books-kavita  | 2024-12-06T14:37:00.839803136Z    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
|books-kavita  | 2024-12-06T14:37:00.839828140Z    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839848325Z    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839868230Z    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839888205Z    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839907342Z    --- End of inner exception stack trace ---
|books-kavita  | 2024-12-06T14:37:00.839924942Z    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839943101Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.839970340Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.840024189Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.840047866Z    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.840096337Z    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.840109188Z    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841162838Z [Kavita] [2024-12-06 09:37:00.840 -05:00  48] [Error] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] There was an issue adding/updating a person
|books-kavita  | 2024-12-06T14:37:00.841185746Z Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details.
|books-kavita  | 2024-12-06T14:37:00.841195734Z  ---> Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 19: 'FOREIGN KEY constraint failed'.
|books-kavita  | 2024-12-06T14:37:00.841205722Z    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
|books-kavita  | 2024-12-06T14:37:00.841213893Z    at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
|books-kavita  | 2024-12-06T14:37:00.841221506Z    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
|books-kavita  | 2024-12-06T14:37:00.841229538Z    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841237151Z    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841244415Z    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841253424Z    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841261526Z    --- End of inner exception stack trace ---
|books-kavita  | 2024-12-06T14:37:00.841269628Z    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841277869Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841285831Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841294422Z    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841303013Z    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841310765Z    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841331159Z    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841340798Z    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
|books-kavita  | 2024-12-06T14:37:00.841350227Z    at API.Data.UnitOfWork.CommitAsync() in /home/runner/work/Kavita/Kavita/API/Data/UnitOfWork.cs:line 118
|books-kavita  | 2024-12-06T14:37:00.841358747Z    at API.Helpers.PersonHelper.UpdateChapterPeopleAsync(Chapter chapter, IList`1 people, PersonRole role, IUnitOfWork unitOfWork) in /home/runner/work/Kavita/Kavita/API/Helpers/PersonHelper.cs:line 171
|books-kavita  | 2024-12-06T14:37:00.841367408Z    at API.Services.Tasks.Scanner.ProcessSeries.UpdateChapterPeopleAsync(Chapter chapter, IList`1 people, PersonRole role) in /home/runner/work/Kavita/Kavita/API/Services/Tasks/Scanner/ProcessSeries.cs:line 1022

This occurred when importing a new library of eBooks, seems to be an issue with the authors? It's a constant stream of these across tons of entries, so please let me know if there is more I can help with to debug.

What did you expect?

Successful imports

Kavita Version Number - If you don not see your version number listed, please update Kavita and see if your issue still persists.

0.8.4.2 - Stable

What operating system is Kavita being hosted from?

Docker (Dockerhub Container)

If the issue is being seen on Desktop, what OS are you running where you see the issue?

None

If the issue is being seen in the UI, what browsers are you seeing the problem on?

No response

If the issue is being seen on Mobile, what OS are you running where you see the issue?

None

If the issue is being seen on the Mobile UI, what browsers are you seeing the problem on?

No response

Relevant log output

See above.

Additional Notes

No response

@Fmstrat Fmstrat added the needs-triage Needs to be triaged by a developer and assigned a release label Dec 6, 2024
@majora2007
Copy link
Member

These are hard to reproduce issues and even though I rewrote the scanner in v0.8.4, I'm still unable to hammer it out completely. The best way to "fix" is to stop Kavita and rescan.

After having spent nearly 2 months reworking just the scanner, this issue is something I'm really unable to solve. I'll probably take another stab at it next year, but I'm out of steam with this elusive bug.

@github-project-automation github-project-automation bot moved this to To do in Backlog Dec 8, 2024
@majora2007 majora2007 added the help wanted Extra attention is needed label Dec 8, 2024
@Fmstrat
Copy link
Author

Fmstrat commented Dec 9, 2024

@majora2007 I can imagine. If I can reproduce reliably, I'll try to debug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed needs-triage Needs to be triaged by a developer and assigned a release
Projects
Status: To do
Development

No branches or pull requests

2 participants