Guard the provider cache against concurrent access - #5765
Open
btwshivam wants to merge 1 commit into
Open
Conversation
Signed-off-by: btwshivam <shivam.devline@gmail.com>
btwshivam
requested review from
diocas,
glpatcern,
jessegeens and
rawe0
as code owners
August 11, 2026 11:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
getOIDCProviderForIssuerreads and writesam.providerswith no lock, which the code already flags with// FIXME: op not atomic.two logins landing together for an issuer that isn't cached yet race on that map. Go doesn't make this a panic, it's
fatal error: concurrent map writes, so neither recover() nor the grpc recovery interceptor catches it and revad exits.map is empty after every restart, so the window is the first logins after one, which is also when a lot of people tend to log in at once. With more than one issuer configured a read racing a write is equally fatal, so it isn't only a startup thing.
guarded with a RWMutex and a re-check under the write lock. Discovery stays outside the lock, otherwise one unreachable issuer would block logins for every other issuer, and goes through a singleflight group so a burst costs the IdP one request instead of one per caller.
Testing
ran with
-raceagainst master the same tests report the data race and die with the fatal error, with the fix they pass. also assert that concurrent logins cause a single discovery request, dropping the singleflight makes that fail