-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Long running test: ReadAsync_CancelPendingTask_ThrowsCancellationException and ReadAsync_CancelPendingValueTask_ThrowsCancellationException #72586
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsCouldn't add runfo information since the work item has the same name as previously fixed issues. But this timeout behavior has occurred in the following rolling build runs: The timeout occurs when executing the long-running test Related to #72209
|
Triage: regression introduced on 7/20. High frequency, we should disable it ASAP. |
@stephentoub I asked @rzikm to disable the test. Do you plan to do more (curious about your self-assignment). |
I changed this test yesterday. |
I'm having trouble reproing locally. The changes I made yesterday were:
Re-reviewing, I think the tests are valid. Most likely there's some race condition somewhere in the implementation of either SocketsHttpHandler or the test stream it's using that causes the waiting for cancellation in these tests to hang. But it's hard to say for sure without a repro. I've unassigned myself. |
|
The issue here stems from HttpConnection not passing the CancellationToken down into the underlying Stream.ReadAsync operations and instead registering with the token to Dispose of the stream if cancellation is requested. That causes a problem for this specific test because the test is simply issuing a read (with no writes) and waiting for a cancellation request. And while it sounds like the issue there has to do with the token not canceling the read, it's actually that the token is the only thing keeping alive all of the state associated with the test. By not passing the token in, everything becomes available for collection because the timer that would be rooting the whole operation doesn't get handed a reference to the leaf async state machine. |
I was running with change @stephentoub suggested as try and the issue disappears
While this is test change, we should still keep this issue open for product fix. Since this is now understood and it seems like it is very corner case specific to not using the stream after cancelation and using special in-memory stream, I'm going to move it to future (and leave the tests disabled for now) |
@wfurt can you please clarify what kind of product change is needed? |
yes @karelz. HttpConnection use token registration to dispose underlying stream on cancelation. However, because we don't pass it into the stream, it is not root and eligible for collection in this particular test. When the finalizer runs, we skip the cleanup logic in Dispose and the task hangs. |
@stephentoub isn't the issue more so that when we register for cancellation on I am not sure I understand this comment given that we always control the registrations ourselves internally: runtime/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs Lines 902 to 903 in 916f1ad
|
Not really. That was by design, and because of that, what I wrote holds.
If memory serves, the concern was that we're awaiting on the Read/WriteAsync operations on the underlying stream, and if those operations didn't end up rooting their continuations, the connection object could/should get collected, but storing a strong reference to it into the token would thwart that. Basically exactly what this test is showing is a possibility. We could decide we no longer care about that, of course. |
Long running tests:
ReadAsync_CancelPendingTask_ThrowsCancellationException
(disabled in PR Disable long running ReadAsync_CancelPendingTask_ThrowsCancellationException tests for some Http1 cases #72596 on 7/21)System.Net.Http.Functional.Tests.Http1CloseResponseStreamConformanceTests.ReadAsync_CancelPendingTask_ThrowsCancellationException
- Http1CloseResponseStreamConformanceTestsSystem.Net.Http.Functional.Tests.Http1RawResponseStreamConformanceTests.ReadAsync_CancelPendingTask_ThrowsCancellationException
- Http1RawResponseStreamConformanceTestsReadAsync_CancelPendingValueTask_ThrowsCancellationException
(disabled in PR Disable ReadAsync_CancelPendingValueTask_ThrowsCancellationException for Http1 #72854 on 7/27)System.Net.Http.Functional.Tests.Http1RawResponseStreamConformanceTests.ReadAsync_CancelPendingValueTask_ThrowsCancellationException
- Http1RawResponseStreamConformanceTestsSystem.Net.Http.Functional.Tests.Http1CloseResponseStreamConformanceTests.ReadAsync_CancelPendingValueTask_ThrowsCancellationException
- Http1CloseResponseStreamConformanceTestsRegression on 7/20
Failures 6/30-8/5:
Given the high frequency, we should disable the test ASAP.
Original report
Couldn't add runfo information since the work item has the same name as previously fixed issues. But this timeout behavior has occurred in the following rolling build runs:
https://dev.azure.com/dnceng/public/_build/results?buildId=1893373&view=results
https://dev.azure.com/dnceng/public/_build/results?buildId=1893617&view=results
https://dev.azure.com/dnceng/public/_build/results?buildId=1893157&view=results
https://dev.azure.com/dnceng/public/_build/results?buildId=1893763&view=results
The timeout occurs when executing the long-running test
System.Net.Http.Functional.Tests.Http1RawResponseStreamConformanceTests.ReadAsync_CancelPendingTask_ThrowsCancellationException
These timeout are occurring on both runtime and runtime-extra-platforms
Related to #72209
Report
Summary
The text was updated successfully, but these errors were encountered: