Skip to content
This repository was archived by the owner on Apr 30, 2025. It is now read-only.

Commit 4b605dd

Browse files
maxmoehlgeofffranks
authored andcommitted
fix(trace): remove GotConn delay
The delay causes a race condition in the go transport that results in a 502 Bad Gateway with: `endpoint_failure (readLoopPeekFailLocked: %!w(<nil>))`. This happens because the transport peeks the first few bytes on the connection and gets some data even though it doesn't expect any. This causes it to go into an error state even though there is no error resulting in the formatting directive to break. This commit removes the delay and adds a note why we can't do this for now. This will reduce the amount of requests we can retry because the client will send data before we know that the connection is good. After we sent _some_ data we can't be sure that the server hasn't started processing, hence no retry in such cases. See: https://cloudfoundry.slack.com/archives/C033ALST37V/p1680888356483179 See: golang/go#31259 Resolves: cloudfoundry/routing-release#316
1 parent 93ddb36 commit 4b605dd

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

proxy/round_tripper/trace.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,14 @@ func traceRequest(req *http.Request) (*http.Request, *requestTracer) {
9292
GotConn: func(info httptrace.GotConnInfo) {
9393
t.gotConn.Store(true)
9494
t.connInfo.Store(&info)
95-
if !info.Reused {
96-
// FIXME: workaround for https://github.com/golang/go/issues/59310
97-
// This gives net/http: Transport.persistConn.readLoop the time possibly mark the connection
98-
// as broken before roundtrip starts.
99-
time.Sleep(500 * time.Microsecond)
100-
}
95+
// FIXME: due to https://github.com/golang/go/issues/31259 this breaks our acceptance tests and is dangerous
96+
// disabled for now even though this will reduce the number of requests we can retry
97+
// if !info.Reused {
98+
// // FIXME: workaround for https://github.com/golang/go/issues/59310
99+
// // This gives net/http: Transport.persistConn.readLoop the time possibly mark the connection
100+
// // as broken before roundtrip starts.
101+
// time.Sleep(500 * time.Microsecond)
102+
// }
101103
},
102104
DNSStart: func(_ httptrace.DNSStartInfo) {
103105
t.tDNSStart.Store(time.Now().UnixNano())

0 commit comments

Comments
 (0)