Skip to content

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.

Change chunk size to be a fixed 50 to validate if it's causing issue with refresh. Added some try catches to see if exceptions are causing issues. (#681)

Joseph Milazzo1d8042015531
diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs
index 281c2e325..d6f032dae 100644
--- a/API/Data/Repositories/SeriesRepository.cs
+++ b/API/Data/Repositories/SeriesRepository.cs
@@ -455,15 +455,15 @@ namespace API.Data.Repositories
// TODO: Think about making this bigger depending on number of files a user has in said library
// and number of cores and amount of memory. We can then make an optimal choice
var totalSeries = await GetSeriesCount(libraryId);
- var procCount = Math.Max(Environment.ProcessorCount - 1, 1);
-
- if (totalSeries < procCount * 2 || totalSeries < 50)
- {
- return new Tuple<int, int>(totalSeries, totalSeries);
- }
-
-
- return new Tuple<int, int>(totalSeries, Math.Max(totalSeries / procCount, 50));
+ // var procCount = Math.Max(Environment.ProcessorCount - 1, 1);
+ //
+ // if (totalSeries < procCount * 2 || totalSeries < 50)
+ // {
+ // return new Tuple<int, int>(totalSeries, totalSeries);
+ // }
+ //
+ // return new Tuple<int, int>(totalSeries, Math.Max(totalSeries / procCount, 50));
+ return new Tuple<int, int>(totalSeries, 50);
}
public async Task<Chunk> GetChunkInfo(int libraryId = 0)
diff --git a/API/Services/MetadataService.cs b/API/Services/MetadataService.cs
index 3a281dc7e..1b5ab0d69 100644
--- a/API/Services/MetadataService.cs
+++ b/API/Services/MetadataService.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -217,9 +218,10 @@ namespace API.Services
var stopwatch = Stopwatch.StartNew();
var totalTime = 0L;
_logger.LogInformation("[MetadataService] Refreshing Library {LibraryName}. Total Items: {TotalSize}. Total Chunks: {TotalChunks} with {ChunkSize} size", library.Name, chunkInfo.TotalSize, chunkInfo.TotalChunks, chunkInfo.ChunkSize);
- // This technically does
+
for (var chunk = 1; chunk <= chunkInfo.TotalChunks; chunk++)
{
+ if (chunkInfo.TotalChunks == 0) continue;
totalTime += stopwatch.ElapsedMilliseconds;
stopwatch.Restart();
_logger.LogInformation("[MetadataService] Processing chunk {ChunkNumber} / {TotalChunks} with size {ChunkSize}. Series ({SeriesStart} - {SeriesEnd}",
@@ -230,23 +232,30 @@ namespace API.Services
PageNumber = chunk,
PageSize = chunkInfo.ChunkSize
});
- _logger.LogDebug($"[MetadataService] Fetched {nonLibrarySeries.Count} series for refresh");
+ _logger.LogDebug("[MetadataService] Fetched {SeriesCount} series for refresh", nonLibrarySeries.Count);
Parallel.ForEach(nonLibrarySeries, series =>
{
- _logger.LogDebug("[MetadataService] Processing series {SeriesName}", series.OriginalName);
- var volumeUpdated = false;
- foreach (var volume in series.Volumes)
+ try
{
- var chapterUpdated = false;
- foreach (var chapter in volume.Chapters)
+ _logger.LogDebug("[MetadataService] Processing series {SeriesName}", series.OriginalName);
+ var volumeUpdated = false;
+ foreach (var volume in series.Volumes)
{
- chapterUpdated = UpdateMetadata(chapter, forceUpdate);
+ var chapterUpdated = false;
+ foreach (var chapter in volume.Chapters)
+ {
+ chapterUpdated = UpdateMetadata(chapter, forceUpdate);
+ }
+
+ volumeUpdated = UpdateMetadata(volume, chapterUpdated || forceUpdate);
}
- volumeUpdated = UpdateMetadata(volume, chapterUpdated || forceUpdate);
+ UpdateMetadata(series, volumeUpdated || forceUpdate);
+ }
+ catch (Exception)
+ {
+ /* Swallow exception */
}
-
- UpdateMetadata(series, volumeUpdated || forceUpdate);
});
if (_unitOfWork.HasChanges() && await _unitOfWork.CommitAsync())