Skip to content
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

net/http: Transport.getConn is wasting one connection sometimes. #60111

Closed
kassiansun opened this issue May 10, 2023 · 1 comment
Closed

net/http: Transport.getConn is wasting one connection sometimes. #60111

kassiansun opened this issue May 10, 2023 · 1 comment

Comments

@kassiansun
Copy link

What version of Go are you using (go version)?

$ go version
go version go1.20.4 darwin/arm64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN="/Users/kassian/.cache/go-path/bin"
GOCACHE="/Users/kassian/Library/Caches/go-build"
GOENV="/Users/kassian/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/kassian/.cache/go-path/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/kassian/.cache/go-path"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/opt/homebrew/Cellar/go/1.20.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.20.4/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
AR="ar"
CC="cc"
CXX="c++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/hk/t8qz75gn6299szmkb94z5ys00000gn/T/go-build874776608=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

We're connection to Elasticsearch from Go, and notice some Connection reset at the Elasticsearch side. After some investigations, it seems that http.Transport.getConn will try to get an idle connection from the pool (queueForIdleConn) and dial the remote host (queueForDial) at the same time. So if the request finished and req.Context cancelled before dial complete, the addTLS step will fail due to context cancelled. Is it possible to continue the dialing and TLS handshake so we can get an usable connection instead of aborting it?

What did you expect to see?

If the req.Context finished before TLS handshake finish, the dialing connection will get closed.

What did you see instead?

The dialing step can finish and the connection can be put into the idle pool.

@seankhliao seankhliao changed the title [net/http]: Transport.getConn is wasting one connection sometimes. net/http: Transport.getConn is wasting one connection sometimes. May 10, 2023
@seankhliao
Copy link
Member

Duplicate of #50984

@seankhliao seankhliao marked this as a duplicate of #50984 May 10, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants