ResourceNotificationService.WatchAsync
is not thread safe
#4606
Labels
area-app-model
Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Milestone
If multiple consumers call
ResourceNotificationService.WatchAsync
in parallel, it looks like some of the subscriptions get lost.Context in which I encountered this - I've been hitting a intermittent deadlocks (roughly 1 in 5 starts) with
WaitForDependencies
since I added my own listener toWatchAsync
in which resources get stuck in theWaiting
state indefinitely.WaitForDependenciesRunningHook
makes it's call toWatchAsync
duringTask.Run
, and I believe that can get delayed long enough to conflict with my ownWatchAsync
call in a differentIDistributedApplicationLifecycleHook
.https://github.com/davidfowl/WaitForDependenciesAspire/blob/22e32d218943bd3b15e85c2f04e6415acff6054f/WaitForDependencies.Aspire.Hosting/WaitForDependenciesExtensions.cs#L146
I suspect the root problem is due to the following not being thread safe:
aspire/src/Aspire.Hosting/ApplicationModel/ResourceNotificationService.cs
Line 128 in 0f4cc84
Repro Code:
Expected Results:
Actual Results
(Execution number varies from run to run, but is always below 100.)
The text was updated successfully, but these errors were encountered: