Jellyfin Forum
Jellyfin fails to completely scan my media library - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: Troubleshooting (https://forum.jellyfin.org/f-troubleshooting)
+---- Forum: Media Scanning & Identification (https://forum.jellyfin.org/f-media-scanning-identification)
+---- Thread: Jellyfin fails to completely scan my media library (/t-jellyfin-fails-to-completely-scan-my-media-library)



Jellyfin fails to completely scan my media library - ZYKerman - 2024-12-25

HINT: I have also submitted this as an issue in Github. You can see more detailed logs and screenshots there:https://github.com/jellyfin/jellyfin/issues/13278

I'm experiencing an issue where my Jellyfin server fails to completely scan my media library. After I hit the "scan all libraries" button, it produces isolated episodes but the whole season does not appear in my anime library. It also fails to recognize some of the anime in my media folder - neither complete season nor isolated episodes appear. Note that all these files are maintained automatically by Sonarr, so they are neatly named and organized and Jellyfin absolutely should have recognized them.
When I dived further, I found that Jellyfin automatically cancelled the scanning process shortly after it was started, amd that the scans will eventually stop at 86.6% with a log output
Code:
[2024-12-25 04:25:07.333 +08:00] [INF] Removing virtual season null in series "某科学的超电磁炮"
[2024-12-25 04:25:07.333 +08:00] [INF] Removing item, Type: "Season", Name: "未知季", Path: "", Id: 060dfd34-9fc0-8f37-59e1-cee853308251
After stopping at this point for a moment, the whole scanning process is terminated. It seems that Jellyfin is trying to delete a phantom season but it is stuck, and that the rest of the library is not scanned at all. Meanwhile, another interesting fact is that SOMETIMES the scanning process stops after an error:
Code:
[2024-12-25 04:07:16.997 +08:00] [ERR] Error executing Scheduled Task
System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.
  at System.Threading.SemaphoreSlim.Release(Int32 releaseCount)
  at MediaBrowser.Providers.Manager.ProviderManager.SaveImage(BaseItem item, String url, ImageType type, Nullable`1 imageIndex, CancellationToken cancellationToken)
  at Emby.Server.Implementations.Library.LibraryManager.ConvertImageToLocal(BaseItem item, ItemImageInfo image, Int32 imageIndex, Boolean removeOnFailure)
  at Emby.Server.Implementations.Library.LibraryManager.UpdateImagesAsync(BaseItem item, Boolean forceUpdate)
  at Emby.Server.Implementations.Library.LibraryManager.RunMetadataSavers(BaseItem item, ItemUpdateType updateReason)
  at Emby.Server.Implementations.Library.LibraryManager.SavePeopleMetadataAsync(IEnumerable`1 people, CancellationToken cancellationToken)
  at Emby.Server.Implementations.Library.LibraryManager.UpdatePeopleAsync(BaseItem item, List`1 people, CancellationToken cancellationToken)
  at MediaBrowser.Providers.Manager.MetadataService`2.SaveItemAsync(MetadataResult`1 result, ItemUpdateType reason, CancellationToken cancellationToken)
  at MediaBrowser.Providers.Manager.MetadataService`2.RefreshMetadata(BaseItem item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
  at MediaBrowser.Providers.TV.SeriesMetadataService.RefreshMetadata(BaseItem item, MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.BaseItem.RefreshMetadata(MetadataRefreshOptions options, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.RefreshAllMetadataForContainer(IMetadataContainer container, MetadataRefreshOptions refreshOptions, IProgress`1 progress, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.RefreshChildMetadata(BaseItem child, MetadataRefreshOptions refreshOptions, Boolean recursive, IProgress`1 progress, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.<>c__DisplayClass69_0`1.<<RunTasks>b__1>d.MoveNext()
--- End of stack trace from previous location ---
  at MediaBrowser.Controller.Entities.Folder.RunTasks[T](Func`3 task, IList`1 children, IProgress`1 progress, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.RefreshChildMetadata(BaseItem child, MetadataRefreshOptions refreshOptions, Boolean recursive, IProgress`1 progress, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.<>c__DisplayClass69_0`1.<<RunTasks>b__1>d.MoveNext()
--- End of stack trace from previous location ---
  at MediaBrowser.Controller.Entities.Folder.RunTasks[T](Func`3 task, IList`1 children, IProgress`1 progress, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.ValidateChildrenInternal2(IProgress`1 progress, Boolean recursive, Boolean refreshChildMetadata, Boolean allowRemoveRoot, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.Folder.ValidateChildrenInternal(IProgress`1 progress, Boolean recursive, Boolean refreshChildMetadata, Boolean allowRemoveRoot, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService, CancellationToken cancellationToken)
  at MediaBrowser.Controller.Entities.AggregateFolder.ValidateChildrenInternal(IProgress`1 progress, Boolean recursive, Boolean refreshChildMetadata, Boolean allowRemoveRoot, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService, CancellationToken cancellationToken)
  at Emby.Server.Implementations.Library.LibraryManager.PerformLibraryValidation(IProgress`1 progress, CancellationToken cancellationToken)
  at Emby.Server.Implementations.Library.LibraryManager.ValidateMediaLibraryInternal(IProgress`1 progress, CancellationToken cancellationToken)
  at Emby.Server.Implementations.ScheduledTasks.ScheduledTaskWorker.ExecuteInternal(TaskOptions options)
[2024-12-25 04:07:16.998 +08:00] [INF] "扫描媒体库" Failed after 1 minute(s) and 40 seconds
Through my observation, I believe that this error ONLY appears when the scanning process is the FIRST scan after the server is (re)started and the following ones do not report any error. The following ones will get stuck, and then exit, with incompletely scanned libraries, but no error in the log file. I know that poor accessibility to metadata providers such as TMDB here in China can be a cause of incomplete scans, but I have already disabled all means of scraping metadata (because the metadata is maintained by Sonarr) so this is definitely not the reason. I don't know why this error appears randomly, and I'm not sure whether it is related to the incomplete scan or not, but something must have gone wrong in my Jellyfin database.
Has anyone else encountered this problem? Are there any known fixes or troubleshooting steps I can try to resolve this issue?
Thank you for your assistance.