mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-01-24 07:30:57 +01:00
[PR #4223] [CLOSED] Make TvdbClientManager thread safe #9778
Labels
No labels
area:database
awaiting-feedback
backend
blocked
breaking change: web api
bug
build
ci
confirmed
discussion needed
dotnet future
downstream
duplicate
EFjellyfin.db
enhancement
feature
future
github-actions
good first issue
hdr
help wanted
invalid
investigation
librarydb
live-tv
lyrics
media playback
music
needs testing
nuget
performance
platform
pull-request
question
regression
release critical
requires-web
roadmap
security
security
stale
support
syncplay
ui & ux
upstream
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: starred/jellyfin#9778
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/jellyfin/jellyfin/pull/4223
Author: @Spacetech
Created: 9/28/2020
Status: ❌ Closed
Base:
master← Head:tvdbclient_thread_safety📝 Commits (4)
49522a4Make TvdbClientManager thread safeb739475update based on suggestions9316336move WaitAsync outside the try statement00e291dMerge branch 'master' into tvdbclient_thread_safety📊 Changes
1 file changed (+96 additions, -50 deletions)
View changed files
📝
MediaBrowser.Providers/Plugins/TheTvdb/TvdbClientManager.cs(+96 -50)📄 Description
Along with #4222, another issue I ran into was when multiple
TvdbClientManagercalls ran concurrently.Here's some errors that will happen if you try that:
It's complaining about setting
AcceptedLanguageand callingAuthenticateAsync.A fix is to have individual clients per language, so
AcceptedLanguageis set once during the initial creation. Along with that, add a locking mechanism to prevent concurrent authentication requests.Changes
ConcurrentDictionaryofTvDbClients per language.GetTvDbClientto return a specific langaugesTvDbClientand make it async so the token methods can be await'dTryGetValueto useGetOrCreateAsync. Something to note is thatMemoryCache.GetOrCreateAsyncis thread safe but has odd behavior (ref 1, ref 2). So it might run the factory a few times for the same key at the start. This is kind of annoying but might not be a huge issue for this use case.UtcNowfor the tokenDateTimesince it's less scary than local times.Issues
None
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.