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: goroutine stuck in waitWrite() #66543

Closed
jimsnab opened this issue Mar 26, 2024 · 1 comment
Closed

net: goroutine stuck in waitWrite() #66543

jimsnab opened this issue Mar 26, 2024 · 1 comment

Comments

@jimsnab
Copy link

jimsnab commented Mar 26, 2024

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jimsnab/.cache/go-build'
GOENV='/home/jimsnab/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jimsnab/go/pkg/mod'
GONOPROXY='github.com/jimsnab'
GONOSUMDB='github.com/jimsnab'
GOOS='linux'
GOPATH='/home/jimsnab/go'
GOPRIVATE='github.com/jimsnab'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3756548279=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Production code using sockets is experiencing hangs requiring forced terminations. The pattern is a server able to send significant stream data, combined with a client that reacts to the data, which takes a little bit of time, and replies. Therefore the server gets ahead of the client and data starts to accumulate in the socket buffers.

What did you see happen?

After attaching some diagnostics, it is observed a net connection Write call isn't returning. It's permanently stuck.

A repro program is provided in this repository. See the readme for repro instructions.

What did you expect to see?

Write completes its task. If the buffer was too full, Write may block initially but should eventually unblock as the client progresses through the stream.

@jimsnab
Copy link
Author

jimsnab commented Mar 26, 2024

Uncovered that the Write will unblock after waiting long enough. In the repro program it will wait for an entire 1MB to drain before resuming. If the client takes many minutes (or hours in my case) to process 1MB of messages, this will look like a hang. There does not seem to be a way to control this behavior.

@jimsnab jimsnab closed this as completed Mar 26, 2024
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

1 participant