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

Goroutine leak in the client in v1.8.5 #231

Closed
improbablepiotr opened this issue May 1, 2020 · 5 comments · Fixed by #238
Closed

Goroutine leak in the client in v1.8.5 #231

improbablepiotr opened this issue May 1, 2020 · 5 comments · Fixed by #238
Labels

Comments

@improbablepiotr
Copy link

improbablepiotr commented May 1, 2020

Hi

I have encountered a goroutine leak in my client using 1.8.5:

goroutine profile: total 2472
2151 @ 0x436bb0 0x40506d 0x404e35 0x8ce854 0x8ce837 0x8cfac2 0x466431
#	0x8ce853	nhooyr.io/websocket.(*mu).forceLock+0x83		/Users/redacted/go/pkg/mod/nhooyr.io/websocket@v1.8.5/conn_notjs.go:234
#	0x8ce836	nhooyr.io/websocket.(*msgWriterState).close+0x66	/Users/redacted/go/pkg/mod/nhooyr.io/websocket@v1.8.5/write.go:224
#	0x8cfac1	nhooyr.io/websocket.(*Conn).close.func1+0x31		/Users/redacted/go/pkg/mod/nhooyr.io/websocket@v1.8.5/conn_notjs.go:142

When we moved back to 1.8.4, the issue has disappeared.

Our client app is a load testing client so it would open connections and then close them to simulate "real" clients connecting, therefore new connections would be opened and for each one, Close method would be called once. If Close leaks a goroutine, a large number of goroutines causes us memory issues.

The server side is NodeJS using ws-7.2.3. We're running all this Linux containers in Kubernetes.

I attempted to write a small repro case in Go (both client and server), with self-signed TLS certs as well to see if TLS could trigger the issue, but I didn't manage to repro the issue with it. AFAIK there isn't anything odd happening while the client and server communicate. Few synchronous messages and then server pushes a few updates. Either side may be the first one to close the connection, but they use close handshake.

Not sure if this is enough details, LMK if there is something else I can look up to help!

@nhooyr
Copy link
Contributor

nhooyr commented May 1, 2020

Thanks for reporting!

Does the profile by any chance show how long forceLock has been blocked? Can you profile a few minutes later and see if the same goroutine is still blocked?

@nhooyr
Copy link
Contributor

nhooyr commented May 10, 2020

Found this, thanks for reporting!

@nhooyr
Copy link
Contributor

nhooyr commented May 10, 2020

Will tag v1.8.6 EOD.

@nhooyr
Copy link
Contributor

nhooyr commented May 18, 2020

Sorry for the delay, tagged v1.8.6 today!

@improbablepiotr
Copy link
Author

I've noticed my notifications were disabled and only just saw this. Thanks a lot @nhooyr for quick response and fixing this, we'll update our dependency. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants