Skip to content

refactor(runtime): start grain activation synchronously - #19

Closed
ReubenBond wants to merge 1 commit into
rb-fix-grain-context-configuration-racefrom
rb-start-activation-synchronously
Closed

refactor(runtime): start grain activation synchronously#19
ReubenBond wants to merge 1 commit into
rb-fix-grain-context-configuration-racefrom
rb-start-activation-synchronously

Conversation

@ReubenBond

Copy link
Copy Markdown
Owner

Follow-up to dotnet#10565 and part of the fix for dotnet#10556. This PR depends on the grain-context configuration contract introduced by dotnet#10565.

Grain activation now starts synchronously on the activation scheduler using Task.RunSynchronously, with the activation installed explicitly as the current RuntimeContext. This ensures construction and activation begin before CreateContext returns while retaining scheduler affinity.

The synchronous transition must run under a clean ExecutionContext; otherwise ambient state such as request or transaction AsyncLocal values can leak into activation. DefaultExecutionContext accesses CoreCLR's internal ExecutionContext.Default using UnsafeAccessor, with a portable fallback which captures an execution context while flow is suppressed. Focused tests verify both the runtime-default and fallback paths isolate ambient state.

Focused validation passed on both net8.0 and net10.0: the default execution-context and grain-context activator tests (3 per framework), grain activator tests (3 per framework), and transaction attribution test (1 per framework).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 408b1948-f836-4328-9b59-c1a6d9504551
@ReubenBond

Copy link
Copy Markdown
Owner Author

Superseded by dotnet#10569.

@ReubenBond ReubenBond closed this Aug 12, 2026
ReubenBond added a commit that referenced this pull request Aug 18, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 21, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 22, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 23, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 24, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 24, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 25, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 26, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
ReubenBond added a commit that referenced this pull request Aug 28, 2026
…tandardized error responses

- Added SendError(string errorCode, string message, bool isRetriable) method to IInboxHandlerContext interface
- Added SendError(Exception exception, bool isRetriable) overload for exception-based error responses
- Implemented both methods in InboxHandlerContext with automatic reply routing
- Reply route key derived from request route (e.g., 'payment/authorize' → 'payment/reply')
- Preserves correlation key from original request for hierarchical workflows
- Safe no-op behavior when envelope has no ReplyTo address (one-way messages)
- ConvertToErrorCode helper converts exception types to error codes (e.g., InvalidOperationException → INVALID_OPERATION)
- GetReplyRouteKey helper determines reply route from request route pattern
- Comprehensive XML documentation with examples for validation errors, transient errors, and permanent errors
- All 445 Orleans.Journaling tests pass

Completes Features #19 and #20 from feature-list.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant