Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +2 |
Retrying the test...
The test is failing at HEAD with a clean tree, nothing to do here I guess.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +1 |
It would be nice to rebase on the tip and rerun the tests.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Auto-Submit | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
net/http: avoid connCount underflow race
Remove a race condition in counting the number of connections per host,
which can cause a connCount underflow and a panic.
The race occurs when:
- A RoundTrip call attempts to use a HTTP/2 roundtripper (pconn.alt != nil)
and receives an isNoCachedConn error. The call removes the pconn from
the idle conn pool and decrements the connCount for its host.
- A second RoundTrip call on the same pconn succeeds,
and delivers the pconn to a third RoundTrip waiting for a conn.
- The third RoundTrip receives the pconn at the same moment its request
context is canceled. It places the pconn back into the idle conn pool.
At this time, the connCount is incorrect, because the conn returned to
the idle pool is not matched by an increment in the connCount.
Fix this by not adding HTTP/2 pconns back to the idle pool in
wantConn.cancel.
Fixes #61474
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[release-branch.go1.25] net/http: avoid connCount underflow race
Remove a race condition in counting the number of connections per host,
which can cause a connCount underflow and a panic.
The race occurs when:
- A RoundTrip call attempts to use a HTTP/2 roundtripper (pconn.alt != nil)
and receives an isNoCachedConn error. The call removes the pconn from
the idle conn pool and decrements the connCount for its host.
- A second RoundTrip call on the same pconn succeeds,
and delivers the pconn to a third RoundTrip waiting for a conn.
- The third RoundTrip receives the pconn at the same moment its request
context is canceled. It places the pconn back into the idle conn pool.
At this time, the connCount is incorrect, because the conn returned to
the idle pool is not matched by an increment in the connCount.
Fix this by not adding HTTP/2 pconns back to the idle pool in
wantConn.cancel.
For #61474
Fixes #75539
Change-Id: I104d6cf85a54d0382eebf3fcf5dda99c69a7c3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/703936
Auto-Submit: Damien Neil <dn...@google.com>
Reviewed-by: Nicholas Husin <hu...@google.com>
Reviewed-by: Nicholas Husin <n...@golang.org>
LUCI-TryBot-Result: Go LUCI <golang...@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 3203a5da290753e5c7aceb12f41f06b272356bd0)
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
index 07b3a9e..2778db3 100644
--- a/src/net/http/transport.go
+++ b/src/net/http/transport.go
@@ -1372,7 +1372,10 @@
w.done = true
w.mu.Unlock()
- if pc != nil {
+ // HTTP/2 connections (pc.alt != nil) aren't removed from the idle pool on use,
+ // and should not be added back here. If the pconn isn't in the idle pool,
+ // it's because we removed it due to an error.
+ if pc != nil && pc.alt == nil {
t.putOrCloseIdleConn(pc)
}
}
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
index 9762f05..28ad3eb 100644
--- a/src/net/http/transport_test.go
+++ b/src/net/http/transport_test.go
@@ -7559,3 +7559,35 @@
})
}
}
+
+func TestIssue61474(t *testing.T) {
+ run(t, testIssue61474, []testMode{http2Mode})
+}
+func testIssue61474(t *testing.T, mode testMode) {
+ if testing.Short() {
+ return
+ }
+
+ // This test reliably exercises the condition causing #61474,
+ // but requires many iterations to do so.
+ // Keep the test around for now, but don't run it by default.
+ t.Skip("test is too large")
+
+ cst := newClientServerTest(t, mode, HandlerFunc(func(rw ResponseWriter, req *Request) {
+ }), func(tr *Transport) {
+ tr.MaxConnsPerHost = 1
+ })
+ var wg sync.WaitGroup
+ defer wg.Wait()
+ for range 100000 {
+ wg.Go(func() {
+ ctx, cancel := context.WithTimeout(t.Context(), 1*time.Millisecond)
+ defer cancel()
+ req, _ := NewRequestWithContext(ctx, "GET", cst.ts.URL, nil)
+ resp, err := cst.c.Do(req)
+ if err == nil {
+ resp.Body.Close()
+ }
+ })
+ }
+}
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[release-branch.go1.24] net/http: avoid connCount underflow race
Remove a race condition in counting the number of connections per host,
which can cause a connCount underflow and a panic.
The race occurs when:
- A RoundTrip call attempts to use a HTTP/2 roundtripper (pconn.alt != nil)
and receives an isNoCachedConn error. The call removes the pconn from
the idle conn pool and decrements the connCount for its host.
- A second RoundTrip call on the same pconn succeeds,
and delivers the pconn to a third RoundTrip waiting for a conn.
- The third RoundTrip receives the pconn at the same moment its request
context is canceled. It places the pconn back into the idle conn pool.
At this time, the connCount is incorrect, because the conn returned to
the idle pool is not matched by an increment in the connCount.
Fix this by not adding HTTP/2 pconns back to the idle pool in
wantConn.cancel.
For #61474
Fixes #75538
Change-Id: I104d6cf85a54d0382eebf3fcf5dda99c69a7c3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/703936
Auto-Submit: Damien Neil <dn...@google.com>
Reviewed-by: Nicholas Husin <hu...@google.com>
Reviewed-by: Nicholas Husin <n...@golang.org>
LUCI-TryBot-Result: Go LUCI <golang...@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 3203a5da290753e5c7aceb12f41f06b272356bd0)
diff --git a/src/net/http/transport.go b/src/net/http/transport.go
index 41e6741..200fe7b 100644
--- a/src/net/http/transport.go
+++ b/src/net/http/transport.go
@@ -1372,7 +1372,10 @@
w.done = true
w.mu.Unlock()
- if pc != nil {
+ // HTTP/2 connections (pc.alt != nil) aren't removed from the idle pool on use,
+ // and should not be added back here. If the pconn isn't in the idle pool,
+ // it's because we removed it due to an error.
+ if pc != nil && pc.alt == nil {
t.putOrCloseIdleConn(pc)
}
}
diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go
index a454db5..4ac0e51 100644
Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Commit-Queue | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +2 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +2 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Code-Review | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
The trybot result shows that 1.24 backport needs more work, as it doesn't have WaitGroup.Go.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
The trybot result shows that 1.24 backport needs more work, as it doesn't have WaitGroup.Go.
Initially missed that. Done.
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
TryBot-Bypass | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Reviewed-on: https://go-review.googlesource.com/c/go/+/705377
TryBot-Bypass: Carlos Amedee <car...@golang.org>
Reviewed-by: Cherry Mui <cher...@google.com>
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[release-branch.go1.25] net/http: avoid connCount underflow race
Remove a race condition in counting the number of connections per host,
which can cause a connCount underflow and a panic.
The race occurs when:
- A RoundTrip call attempts to use a HTTP/2 roundtripper (pconn.alt != nil)
and receives an isNoCachedConn error. The call removes the pconn from
the idle conn pool and decrements the connCount for its host.
- A second RoundTrip call on the same pconn succeeds,
and delivers the pconn to a third RoundTrip waiting for a conn.
- The third RoundTrip receives the pconn at the same moment its request
context is canceled. It places the pconn back into the idle conn pool.
At this time, the connCount is incorrect, because the conn returned to
the idle pool is not matched by an increment in the connCount.
Fix this by not adding HTTP/2 pconns back to the idle pool in
wantConn.cancel.
For #61474
Fixes #75539
Change-Id: I104d6cf85a54d0382eebf3fcf5dda99c69a7c3f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/703936
Auto-Submit: Damien Neil <dn...@google.com>
Reviewed-by: Nicholas Husin <hu...@google.com>
Reviewed-by: Nicholas Husin <n...@golang.org>
LUCI-TryBot-Result: Go LUCI <golang...@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit 3203a5da290753e5c7aceb12f41f06b272356bd0)
Reviewed-on: https://go-review.googlesource.com/c/go/+/705376
Reviewed-by: Cherry Mui <cher...@google.com>
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |