Skip to content

net/http: IdleConnTimeout is invalid for HTTP/2 #69205

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

Open
ahajunzi opened this issue Sep 2, 2024 · 3 comments
Open

net/http: IdleConnTimeout is invalid for HTTP/2 #69205

ahajunzi opened this issue Sep 2, 2024 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@ahajunzi
Copy link

ahajunzi commented Sep 2, 2024

Go version

go version go1.22.2 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/data/home/sakiluzhang/.cache/go-build'
GOENV='/data/home/sakiluzhang/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/data/home/sakiluzhang/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/data/home/sakiluzhang/go'
GOPRIVATE=''
GOPROXY='https://sakiluzhang:[email protected]'
GOROOT='/data/home/sakiluzhang/go'
GOSUMDB='sum.woa.com+643d7a06+Ac5f5VOC4N8NUXdmhbm8pZSXIWfhek5JSmWdWrq7pLX4'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/data/home/sakiluzhang/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/data/home/sakiluzhang/DServer/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build929430334=/tmp/go-build -gno-record-gcc-switches'

What did you do?

func (t *Transport) tryPutIdleConn(pconn *persistConn) error {

	if t.DisableKeepAlives || t.MaxIdleConnsPerHost < 0 {
		return errKeepAlivesDisabled
	}
	if pconn.isBroken() {
		return errConnBroken
	}
	pconn.markReused()

	t.idleMu.Lock()
	defer t.idleMu.Unlock()

	// HTTP/2 (pconn.alt != nil) connections do not come out of the idle list,
	// because multiple goroutines can use them simultaneously.
	// If this is an HTTP/2 connection being “returned,” we're done.
	if pconn.alt != nil && t.idleLRU.m[pconn] != nil {
             **here pconn.idleAt has not been updated and returned.**
		return nil
	}
       ......

What did you see happen?

I hope one connection is checked IdleConnTimeout should start at the latest time I used it rather than the first time

I hope *http.Transport.idleLRU list should remove connection not only by MaxIdleConns (in many cases, you can't estimate proper num for in China there maybe Tens of millions users use our product simultaneously and more http requests will be produced) but also by IdleConnTimeout

What did you expect to see?

read above

@ianlancetaylor
Copy link
Member

CC @neild

@neild
Copy link
Contributor

neild commented Sep 3, 2024

The HTTP/2 idle timeout is handled in the HTTP/2 transport:
https://go.googlesource.com/net/+/refs/tags/v0.28.0/http2/transport.go#862

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 4, 2024
@dmitshur dmitshur added this to the Backlog milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants