net/http: finishRequest() aborts ongoing background reads #17559
Comments
I haven't looked into this yet. To clarify, are you saying this is a regression since faf882d (golang.org/cl/31173)? |
Regression: Yes. I think so. |
dhananjay92
added a commit
to dhananjay92/go
that referenced
this issue
Oct 23, 2016
http.response.finishRequest() calls abortPendingRead() which then aborts the background reads. It should not abort background reads, but wait for them to finish. This CL, 1. changes abortPendingRead() to finishPendingRead() with option for aborting. Now for normal requests, it won't abort connections. 2. Sets the Read/Write deadlines for both TLS and TCP connections. Previously, it only set deadlines for TLS leading to deadlocks. These deadlocks went unnoticed because with abortPendingRead() everything was getting aborted all the time. 3. Ensures sensible default timeout values. Fixes golang#17559.
CL https://golang.org/cl/31755 mentions this issue. |
From offline discussion with Brad & Joe: It's okay for finishRequest() to abort backgroundRead() every time. The imeplementation of This is WAI. So closing this. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
[ continued from Issue #17547 ]
TL;DR:
abortPendingRead()
is called fromfinishRequest()
, causing it to abort ongoing reads. This causesdeadline_exceeded
errors.finishRequest()
should wait for reads to finish in normal case.Consider following sequence of events from
http.conn.serve()
:startBackgroundRead()
startsbackgroundRead()
in another goroutine.backgroundRead()
from above step does not finish until after the next step. (Simulated by adding sleep)finishRequest()
called, which callsabortPendingRead()
. abortPendingRead() then proceeds to abort ongoing background reads by setting the read deadline toaLongTimeAgo
. This causes the ongoing reads to reportdeadline_exceeded
./cc @bradfitz @dsnet @mdempsky
The text was updated successfully, but these errors were encountered: