dotnet / dotnet/orleans

Codegen does not convert [Unordered] interface attribute into method metadata InvokeMethodOptions.Unordered + Proposed Fix

Open
#9,149 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
10.9k
Forks
2.1k
Avg merge
14h 42m
Merged PRs (30d)
354

Description

In principle, [Unordered] is applied to grain interfaces to instruct gateway connection selection to be round-robin instead of hashed to GrainId. However, the test "TestWithConstantId_ExpectTwo" depicted in this [gist](https://gist.github.com/MarkNickeson/37a336f545087ed8df1c75f984c17236) demonstrates that round-robin behavior does not occur. Debugging into source, the key finding is that metadata for methods within interfaces decorated with [Unordered] indicates InvokeMethodOptions.None rather than including the required InvokeMethodOptions.Unordered.

A potential solution would require revision to [InvokableMethodDescription.cs](https://github.com/dotnet/orleans/blob/ad8d22d3e6427ebb6af5ffe32a5c3b911b7595ec/src/Orleans.CodeGenerator/Model/InvokableMethodDescription.cs). However, this is potentially risky given that other important Orleans capabilities such as reminders make use of [Unordered] - the potential for unintended consequences seems high.

To fix the problem, pseudo-code similar to below must be added to the ctor in InvokableMethodDescription.cs:

if containingInterface is decorated with UnorderedAttribute
{
CustomInitializerMethods.Add(("AddInvokeMethodOptions",InvokeMethodOptions.Unordered))
}

Contributor guide

Open the contributing guide

Research direction

Start by reading src/Orleans.CodeGenerator/Model/InvokableMethodDescription.cs and reviewing the TestWithConstantId_ExpectTwo example in the linked gist. Confirm how an interface decorated with UnorderedAttribute produces InvokeMethodOptions metadata, then verify the fix restores round-robin gateway selection without affecting other UnorderedAttribute uses such as reminders.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.