Kareadita / Kavita

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
http://www.kavitareader.com
GNU General Public License v3.0
6.11k stars 316 forks source link

Again "There was an issue writing to the DB for Series XXXX" in 0.8.1.0 #2971

Open janaxhell opened 4 months ago

janaxhell commented 4 months ago

What happened?

I had this problem in the past, but majora helped me sort it out on Discord, then it updated the 0.7.1 and apparently solved the issue, but now I'm on 0.8.1.0 and each monday morning I see tons of these errors and a lot of RAM used:

There was an issue writing to the DB for Series Skeeters

The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.

Restarting the service doesn't help.

What did you expect?

No errors.

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

0.8.1 - Stable

What operating system is Kavita being hosted from?

Docker (Other)

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?

Other (List in "Additional Notes" box)

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

Android

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

Chrome

Relevant log output

Most recent piece of log while scanning:

Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithRowsAffectedOnlyAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at API.Data.UnitOfWork.CommitAsync() in /home/runner/work/Kavita/Kavita/API/Data/UnitOfWork.cs:line 92
   at API.Services.Tasks.Scanner.ProcessSeries.ProcessSeriesAsync(IList`1 parsedInfos, Library library, Boolean forceUpdate) in /home/runner/work/Kavita/Kavita/API/Services/Tasks/Scanner/ProcessSeries.cs:line 190
[Kavita] [2024-05-27 11:23:16.413 +02:00  274] [Information] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Beginning series update on Werewolf By Night: The Complete Collection, Forced: false
[Kavita] [2024-05-27 11:23:16.470 +02:00  274] [Information] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Processing series Werewolf By Night: The Complete Collection
[Kavita] [2024-05-27 11:23:16.470 +02:00  274] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Updating 1 volumes on Werewolf By Night: The Complete Collection
[Kavita] [2024-05-27 11:23:16.470 +02:00  274] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Parsing Werewolf By Night: The Complete Collection - Volume 2017
[Kavita] [2024-05-27 11:23:16.505 +02:00  274] [Debug] API.Services.Tasks.Scanner.ProcessSeries Updating Werewolf By Night: The Complete Collection FolderPath to /comics/Mylar/Marvel
[Kavita] [2024-05-27 11:23:16.505 +02:00  274] [Debug] API.Services.Tasks.Scanner.ProcessSeries Updating Werewolf By Night: The Complete Collection LowestFolderPath to /Marvel/Werewolf By Night The Complete Collection (2017)

Additional Notes

I'm running image: jvmilazz0/kavita:latest on OMV6/Docker, I have a library of about 200k comics + 10k books.

fmunim commented 4 months ago

Having same issue

DoctorD1501 commented 4 months ago

Also having the same issue (on Windows, no docker, 0.8.1.0). Also tried with a fresh install and still getting this, but after it scans in a bunch of comics - the problem did not happen right away (It managed to scan in about 30,050 books before this happened). Comic files are located on network attached storage mounted as a network drive via SMB, library type is Comicvine comics. There should not have been any underlying file changes to the files during the scan as comicrack was closed during the scan and mylar did not download anything during the scan (though even if it did, that should be handled somehow by triggering a rescan of the affected folders or something).

The comic book that gets complained about in the error then does not get added to the database on the scan and furthermore does not seem to add it back on subsequent scans. It thinks it was already added somehow? Or the folder was already successfully scanned?

majora2007 commented 4 months ago

@DoctorD1501 That indicates that your OS is reporting changes in last write time since Kavita last scanned. If it reports that it's changed since Kavita last scanned, Kavita will dive further into the folder.

Janaxhell's issue is different. If you need support, please create another issue or better join the discord and get some.

DoctorD1501 commented 4 months ago

Perhaps my description of events was sort of confusing and made it seem like I was reporting a different error than the original one above. Happy to create a new issue if needed, but the error seems the same. I just wanted to add some flavor in how I got the same error in case that helped to track the issue down. I've got hundreds of errors like this one in the log. Here is one of them (and note that the comic shown in the stack trace below never added after it hits this error the first time Kavita sees it, even on subsequent scans, that was I think the point I was trying to make):

Update: The missing series finally seemed to have scanned in, like a day later. Weird.

[Kavita] [2024-06-04 19:31:41.160 -07:00  44] [Information] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Beginning series update on E.V.I.L. Heroes (2016), Forced: false
[Kavita] [2024-06-04 19:31:41.162 -07:00  44] [Information] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Processing series E.V.I.L. Heroes (2016)
[Kavita] [2024-06-04 19:31:41.162 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Updating 1 volumes on E.V.I.L. Heroes (2016)
[Kavita] [2024-06-04 19:31:41.162 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Parsing E.V.I.L. Heroes (2016) - Volume 2016
[Kavita] [2024-06-04 19:31:41.162 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Adding new chapter, E.V.I.L. Heroes (2016) - Vol 2016 Ch 1
[Kavita] [2024-06-04 19:31:41.280 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Adding new chapter, E.V.I.L. Heroes (2016) - Vol 2016 Ch 2
[Kavita] [2024-06-04 19:31:41.363 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Adding new chapter, E.V.I.L. Heroes (2016) - Vol 2016 Ch 3
[Kavita] [2024-06-04 19:31:41.438 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Adding new chapter, E.V.I.L. Heroes (2016) - Vol 2016 Ch 4
[Kavita] [2024-06-04 19:31:41.491 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Adding new chapter, E.V.I.L. Heroes (2016) - Vol 2016 Ch 5
[Kavita] [2024-06-04 19:31:41.529 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] Adding new chapter, E.V.I.L. Heroes (2016) - Vol 2016 Ch 6
[Kavita] [2024-06-04 19:31:42.609 -07:00  44] [Error] API.Services.Tasks.Scanner.ProcessSeries There was some issue when updating chapter's metadata
Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithRowsAffectedOnlyAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at API.Data.UnitOfWork.CommitAsync() in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Data\UnitOfWork.cs:line 92
   at API.Services.Tasks.Scanner.TagManagerService.GetPerson(String name, PersonRole role) in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Services\Tasks\Scanner\TagManagerService.cs:line 163
   at API.Services.Tasks.Scanner.ProcessSeries.UpdatePeople(Chapter chapter, IList`1 people, PersonRole role) in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Services\Tasks\Scanner\ProcessSeries.cs:line 929
   at API.Services.Tasks.Scanner.ProcessSeries.UpdateChapterFromComicInfo(Chapter chapter, ComicInfo comicInfo, Boolean forceUpdate) in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Services\Tasks\Scanner\ProcessSeries.cs:line 853
   at API.Services.Tasks.Scanner.ProcessSeries.UpdateVolumes(Series series, IList`1 parsedInfos, Boolean forceUpdate) in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Services\Tasks\Scanner\ProcessSeries.cs:line 630
[Kavita] [2024-06-04 19:31:42.612 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries Updating E.V.I.L. Heroes (2016) FolderPath to F:/Comics/Zenescope Entertainment
[Kavita] [2024-06-04 19:31:42.612 -07:00  44] [Debug] API.Services.Tasks.Scanner.ProcessSeries Updating E.V.I.L. Heroes (2016) LowestFolderPath to F:/Comics/Zenescope Entertainment/E.V.I.L. Heroes (2016)
[Kavita] [2024-06-04 19:31:43.920 -07:00  44] [Fatal] API.Services.Tasks.Scanner.ProcessSeries [ScannerService] There was an issue writing to the database for series E.V.I.L. Heroes (2016)
Microsoft.EntityFrameworkCore.DbUpdateConcurrencyException: The database operation was expected to affect 1 row(s), but actually affected 0 row(s); data may have been modified or deleted since entities were loaded. See https://go.microsoft.com/fwlink/?LinkId=527962 for information on understanding and handling optimistic concurrency exceptions.
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ThrowAggregateUpdateConcurrencyExceptionAsync(RelationalDataReader reader, Int32 commandIndex, Int32 expectedRowsAffected, Int32 rowsAffected, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeResultSetWithRowsAffectedOnlyAsync(Int32 commandIndex, RelationalDataReader reader, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.AffectedCountModificationCommandBatch.ConsumeAsync(RelationalDataReader reader, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
   at API.Data.UnitOfWork.CommitAsync() in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Data\UnitOfWork.cs:line 92
   at API.Services.Tasks.Scanner.ProcessSeries.ProcessSeriesAsync(IList`1 parsedInfos, Library library, Boolean forceUpdate) in C:\Users\josep\Documents\Projects\KavitaOrg\Kavita\API\Services\Tasks\Scanner\ProcessSeries.cs:line 190
janaxhell commented 3 months ago

Small update: today, like every monday, I checked what Kavita was doing, and it was scanning library as usual, but this time for no apparent reason, without any red error (I'm writing in the afternoon, and errors were already there early in the morning all the previous times). The version is still 0.8.1.0, so I don't know why it suddenly works fine. Anyway I hope this issue gets sorted out, it disappeared the same random way it appeared. And who knows what will happen next monday.

janaxhell commented 2 months ago

With v0.8.2.0 no problem occurred. The recurring weekly Library Scan task on 150,621 cbz files takes about 36 hours to complete.