AzureAD / azure-activedirectory-identitymodel-extensions-for-dotnet

IdentityModel extensions for .Net
MIT License
1.06k stars 402 forks source link

[Bug] Microsoft.IdentityModel.Protocols.ConfigurationManager.UpdateCurrentConfiguration blocks the system #2959

Closed jw444 closed 2 days ago

jw444 commented 4 weeks ago

Which version of Microsoft.IdentityModel are you using? 8.0.2

Note that to get help, you need to run the latest version.

Where is the issue?

Is this a new or an existing app? a. The app is in production and I have upgraded to a new version of Microsoft.IdentityModel.*

We host a web service (CSES) on Azure. After a recent upgrade of the Microsoft.IdentityModel packages, our service became irresponsive when the load is high. The dump shows that most of the thread (more than 3000) are stuck waiting for something. Here is the call stack:

ntdll.dll!NtWaitForMultipleObjects()    Unknown

KERNELBASE.dll!WaitForMultipleObjectsEx() Unknown [Managed to Native Transition]
mscorlib.dll!System.Threading.ManualResetEventSlim.Wait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown mscorlib.dll!System.Threading.Tasks.Task.SpinThenBlockingWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown mscorlib.dll!System.Threading.Tasks.Task.InternalWait(int millisecondsTimeout, System.Threading.CancellationToken cancellationToken) Unknown mscorlib.dll!System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task task) Unknown [Waiting on Async Operation, double-click or press enter to view Async Call Stacks] Microsoft.IdentityModel.Protocols.dll!Microsoft.IdentityModel.Protocols.ConfigurationManager.UpdateCurrentConfiguration() Line 320 C# mscorlib.dll!System.Threading.Tasks.Task.Execute() Unknown mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown mscorlib.dll!System.Threading.Tasks.Task.ExecuteWithThreadLocal(ref System.Threading.Tasks.Task currentTaskSlot) Unknown mscorlib.dll!System.Threading.Tasks.Task.ExecuteEntry(bool bPreventDoubleExecution) Unknown mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown [Native to Managed Transition]
kernel32.dll!BaseThreadInitThunk() Unknown ntdll.dll!RtlUserThreadStart() Unknown

Is this a known issue? Any solutions? We are running .net framework 4.7.2. The version for Microsoft.IdentityModel.Protocols.dll is 8.0.2.

pmaytak commented 3 weeks ago

@jw444 This may have been fixed in 8.1.1. Can you try to repro with the latest 8.2.0?

jw444 commented 1 week ago

Thank you @pmaytak. I've upgraded to 8.2.0, and the tests so far seem to show that the issue is indeed fixed.