-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrent DownstreamApi calls fail after a while with: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct. #3228
Comments
In the constructor for This seems unintentional and this should probably instead create a copy of the dictionary to mutate. Between microsoft-identity-web/src/Microsoft.Identity.Web.DownstreamApi/DownstreamApi.cs Lines 539 to 560 in d552f4a
It looks like this may be propagating all the way down. Most likely before |
Thanks for the investigation @msbw2 and for the bug report @Rans4ckeR, looking into it. |
I can repro this in Microsoft.Identity.Client by running in a tight loop. |
We will fix this in MSAL AzureAD/microsoft-authentication-library-for-dotnet#5108 |
Fix is merged and will be available in the next MSAL release, 4.68.0, ETA Feb 10 |
Microsoft.Identity.Web Library
Microsoft.Identity.Web.DownstreamApi
Microsoft.Identity.Web version
3.6.2
Web app
Not Applicable
Web API
Not Applicable
Token cache serialization
In-memory caches
Description
We are using a .NET 9 Microsoft.NET.Sdk.Worker daemon application that continuously and concurrently calls IDownstreamApi.PostForAppAsync() to process individual units of work. This is a high throughput real-time processing engine that uses 30 concurrent threads all using the same IDownstreamApi instance.
This works very well with all Microsoft.Identity.Web versions so far, until updating to any 3.6.x version.
It can take a few hours but eventually every call to the IDownstreamApi will fail until we restart the daemon application.
Could this be related to #3202?
Reproduction steps
Error message
Id Web logs
No response
Relevant code snippets
Regression
3.5.0
Expected behavior
Don't trigger
ThrowInvalidOperationException_ConcurrentOperationsNotSupported()
insideSystem.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
.The text was updated successfully, but these errors were encountered: