-
Notifications
You must be signed in to change notification settings - Fork 110
Fix blocking ParameterResource.Value calls to prevent deadlocks in Aspire 9.4+ #763
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
Conversation
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
@davidfowl is this looking like the right direction for a starting point? I assume that we'll need to have this updated for use 9.4 before the code will compile |
@copilot cast the ParameterResource instance to IValueProvider and then call GetValueAsync on it. |
Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Applied the IValueProvider cast pattern as requested. Updated ActiveMQ health check and all test assertions to use Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@aaronpowell should be doable without referencing 9.4 |
Cool - wasn't sure if it was an API added to 9.4. |
It was but there's a way to go async pre 9.4 as well, at least in the calling pattern. |
src/CommunityToolkit.Aspire.Hosting.Minio/MinioBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.Minio/MinioBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.Redis.Extensions/RedisBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.Redis.Extensions/RedisBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/PostgresBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
You're correct - there are still blocking These cases are different from the DbGate blocking calls that were the primary focus of the original issue. The environment callback context is synchronous and requires immediate values for JSON serialization. A proper fix would require changing the architecture to use an event-based async pattern instead of the sync environment callback. Would you like me to attempt a refactor to use the async eventing pattern, or should these be documented as known limitations requiring future architectural changes? |
@copilot search the codebase for any more references of |
…c pattern Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
I've completed a comprehensive search and migration of all remaining What was migrated:
What remains (architectural constraints):
These remaining cases require architectural changes to move from synchronous environment callbacks to async eventing patterns, which is beyond the scope of the original deadlock issue. All async pipeline methods and test code now use the proper async patterns. Commit cc185c9 Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
@copilot revert that last change |
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Minimum allowed line rate is |
This PR addresses blocking calls to
ParameterResource.Value
that can cause deadlocks in Aspire 9.4+ due to changes in dotnet/aspire#10354.Problem
The recent changes in dotnet/aspire require migrating from synchronous
ParameterResource.Value
calls to the asynchronousIValueProvider.GetValueAsync
API. Blocking calls to.Value
, especially in asynchronous pipeline methods, risk deadlocking or blocking app host startup.Solution
Primary Fixes (DbGate Integration):
.Value
calls with deferred parameter resolution by passingParameterResource
instances directly to environment variablesFiles Changed:
src/CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions/PostgresBuilderExtensions.cs
src/CommunityToolkit.Aspire.Hosting.SqlServer.Extensions/SqlServerBuilderExtensions.cs
src/CommunityToolkit.Aspire.Hosting.MySql.Extensions/MySqlBuilderExtensions.cs
src/CommunityToolkit.Aspire.Hosting.Redis.Extensions/RedisBuilderExtensions.cs
Additional Fixes:
GetValueAsync
Example of the fix:
Outstanding Issues
Some configurations (Adminer JSON serialization, Dapr metadata) still use blocking calls due to architectural constraints requiring immediate string values in synchronous environment callbacks. These are documented for future investigation but are beyond the scope of the original issue which focused on async pipeline methods.
Fixes #751.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.