-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Update to cancel downstream operation in TimeoutStrategy.Pessimistic #1697
Update to cancel downstream operation in TimeoutStrategy.Pessimistic #1697
Conversation
…ill cancel downstream operations in TimeoutStrategy.Pessimistic.
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1697 +/- ##
==========================================
+ Coverage 84.63% 84.65% +0.02%
==========================================
Files 306 306
Lines 6819 6831 +12
Branches 1045 1047 +2
==========================================
+ Hits 5771 5783 +12
Misses 839 839
Partials 209 209
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
@martincostello - sorry this is my first PR into Polly. I'm not sure how to go about covering this line? (This is the line it's telling me I'm missing right?) Is it saying I don't have the false condition of the branch, and it's just way off? |
Don't worry about the coverage comment, it's more advisory as long as the PR status checks are green. From looking at it, I think it's impossible to hit anyway. |
Fix wording and add link to issue.
Thanks for the approval @martincostello. Do I need to do anything about the code-ql failure? Is there anything left for me to do? |
No, it's just being especially flaky today and I'm retrying it until it passes 😅 |
This PR has changes to extend the life of the
combinedTokenSource
in theAsyncTimeoutEngine
, so that the cancellation will get propegated downstream in the case of aTimeoutRejectedException
.Pull Request
The issue or feature being addressed
We noticed that the downstream cancellation token was never signaled in
TimeoutStrategy.Pessimistic
. The root cause seems to be theTimeoutRejectionException
escaping the scope of theImplementationAsync
function onAsyncTimeoutEngine.cs:5
. This causes theCancellationTokenSource
to be disposed and the downstream token to never get canceled.This is related to this issue: #722
Details on the issue fix or feature implementation
In this fix we explicitly cancel the
combinedTokenSource
as the function leaves scope, because without the exception will propagate and cause the source to be disposed before the downstream token can be canceled. This issue was demonstrated in a UT. However, that UT requires that we use "real time" as theTimeSpecBase.cs
SystemClock
overrides actually cancel the downstream token themselves on a timeout.Confirm the following