-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Activation cancel logging cleanup #9897
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
base: main
Are you sure you want to change the base?
Conversation
Clean up log levels for intentional cancellation during OnActivateAsync execution.
- Ensures only unexpected activation failures are logged as errors, reducing log noise and improving clarity - Add new error code and log message for disposed object access during activation cancellation - Adjust log levels: cancellation-related exceptions now log at Info/Warning, not Error - Add interfaces and grains to simulate various activation cancellation scenarios - Introduce comprehensive tests to verify correct logging behavior for cancellation vs. non-cancellation exceptions
|
Doesn't .NET include a 'pass the CancellationToken where applicable' analyzer by default? |
src/Orleans.Core.Abstractions/Exceptions/ActivationCancelledException.cs
Outdated
Show resolved
Hide resolved
src/Orleans.Core.Abstractions/Exceptions/ActivationCancelledException.cs
Outdated
Show resolved
Hide resolved
|
I'm not sure about the validity of a |
The .WaitAsync is for cases where the call doesn't accept a CancellationToken, like var reminder = await this.GetReminder("Name").WaitAsync(cancellationToken);This would also apply to other user code that has async calls that don't take a CancellationToken parameter. Without the |
There is but if a different CT is passed then it will not trigger that analyzer but still block the ActivationData await on OnActivateAsync. public override async Task OnActivateAsync(CancellationToken cancellationToken)
{
await base.OnActivateAsync(cancellationToken);
_counter.State.Counter = random.Next(100);
_counter.State.CurrentDateTime = DateTime.UtcNow;
// this call will not trigger the .NET analyzer but continue to block OnActivateAsync as it executes
await _counter.WriteStateAsync(CancellationToken.None);
}Though that would trigger the WaitAsync analyzer, so that's the only one that appears to be necessary (it check for explicitly the OnActivateAsync parameter to be passed in and will suggest WaitAsync in that case). |
|
The analyzer can get split out, too |
Adjusts the log levels so that:
This will clean up logs for proper implementations, add new warning for improper but benign implementations, and keep the Error logs for real errors.
I'll rebase this on top of #9870 once that's merged in so we get proper activity participation in these error/not-error scenarios.
Microsoft Reviewers: Open in CodeFlow