In Dns.RunAsync calls AfterResolution when canceled#104435
In Dns.RunAsync calls AfterResolution when canceled#104435rokonec merged 3 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @dotnet/ncl |
src/libraries/System.Net.NameResolution/System.Net.NameResolution.sln
Outdated
Show resolved
Hide resolved
antonfirsov
left a comment
There was a problem hiding this comment.
What happens if the CancellationToken is fired during the invocation of the delegate passed to prevTask.ContinueWith() (not the previously queued task)? Isn't it possible that both continuation delegates will be invoked leading to double call into AfterResolution?
Also, can we attempt to design a test for this? Idea for a "mini stress test": have a bunch parallel calls in a separate RemoteExecutor process, cancel some of them, count the ResolutionStart & ResolutionStop events.
Because we dont pass CT to func() TLDR: I believe it is OK
Yes it will be nice to have test to validate balanced If this is a high concert I would recommend to handle it in isolated PR, as this requires, IMO, some refactoring and investigations. |
Fixes: #92045
Context
When Dns.RunAsync is canceled before it runs its action, pairing
Log.AfterResolutionwas not called causing permanently incorrect telemetry counters value. See description of #92045Changes
Added
AfterResolutioninOnlyOnCanceledregistered continuation.