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

[v*] Healthcheck goroutine leaks #543

Merged
merged 7 commits into from
Jun 16, 2017
Merged

[v*] Healthcheck goroutine leaks #543

merged 7 commits into from
Jun 16, 2017

Conversation

utrack
Copy link
Contributor

@utrack utrack commented Jun 14, 2017

Hi! This PR fixes goroutine leaks caused by healthcheck not using ctx properly.
I've managed to reproduce it via tests.

@olivere
Copy link
Owner

olivere commented Jun 14, 2017

That looks interesting. Thanks for reporting/fixing it. BTW: Tests fail for Go 1.7 because http.Server in 1.7 doesn't have a Shutdown method.

@utrack
Copy link
Contributor Author

utrack commented Jun 14, 2017

Hmm. Stumbled upon something re: golang/go#20668.

@olivere
Copy link
Owner

olivere commented Jun 14, 2017

@utrack That works as expected here: Context is canceled.

$ go run main.go
Get http://127.0.0.1:57834/: context deadline exceeded
true

@utrack
Copy link
Contributor Author

utrack commented Jun 14, 2017

@olivere on Go 1.8 it works OK, but fails on 1.7.

@olivere
Copy link
Owner

olivere commented Jun 14, 2017

@utrack Oh, I see.

@utrack
Copy link
Contributor Author

utrack commented Jun 14, 2017

I've also prepared v2 backport, should I open up another PR?

@utrack
Copy link
Contributor Author

utrack commented Jun 14, 2017

@olivere Fixed tests for all versions. It's not possible to monitor leaks directly on Go pre-1.8, so I'm using side effects to monitor stuck connections on pre-1.8.

Seems Context is never canceled on 1.7 on server's side because it was not implemented then (but context itself is present in the request). Huh.

@olivere
Copy link
Owner

olivere commented Jun 15, 2017

@utrack Okay, thanks for figuring this out. Can you do three more things for me to merge this into v5:

  1. As far as I can see it, you only have a test to check leaks for healthcheck. Can you also add a test for the sniffNode?
  2. Can you please rename the test for healthcheck from TestRoutineLeaks to TestClientHealthcheckTimeout (or something more expressive). The test for the sniffer should be something like TestClientSnifferTimeout.
  3. Can you move the tests to the end of the other TestClientHealthcheck... (and TestClientSniffer...) tests.

Then we can put together PRs for v2 and v3, or I'll do this in a batch.

@utrack
Copy link
Contributor Author

utrack commented Jun 15, 2017

Sure, done @olivere

@olivere olivere merged commit d30f26a into olivere:release-branch.v5 Jun 16, 2017
@olivere
Copy link
Owner

olivere commented Jun 16, 2017

Merged and will be published soon. Thanks again!

This was referenced Jun 16, 2017
olivere added a commit that referenced this pull request Jun 16, 2017
This is a backport of #543 for elastic.v3 (see also #545).
@olivere
Copy link
Owner

olivere commented Jun 16, 2017

@utrack Do you mind to review #545 (and this commit)? It's this PR backported into elastic.v3.

I will also backport to elastic.v2 later with #546, after merging #503 first.

olivere added a commit that referenced this pull request Jun 16, 2017
This is a backport of #543 for elastic.v3 (see also #546).
@utrack
Copy link
Contributor Author

utrack commented Jun 16, 2017

Reviewed everything :) Looks good, thank you for the client!

@olivere
Copy link
Owner

olivere commented Jun 16, 2017

@utrack Thanks. Have a nice weekend. cu.

@wtfiwtz
Copy link

wtfiwtz commented Jun 21, 2017

 % go build
# gopkg.in/olivere/elastic.v3
../gopkg.in/olivere/elastic.v3/client.go:835: (*http.Request)(req).WithContext undefined (type *http.Request has no field or method WithContext)
../gopkg.in/olivere/elastic.v3/client.go:986: (*http.Request)(req).WithContext undefined (type *http.Request has no field or method WithContext)

Looks like this breaks Go 1.6.2... I'm using elastic.v3... Upgrading Go to 1.8.3 resolved it...

 % wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz
 % sudo tar -C /usr/local -xzf go1.8.3.linux-amd64.tar.gz
 % sudo mv /usr/bin/go /usr/bin/go1.6
 % sudo ln -s /usr/local/go/bin/go /usr/bin/go
 % go version
go version go1.8.3 linux/amd64
 % go build
 %

@olivere
Copy link
Owner

olivere commented Jun 21, 2017

@wtfiwtz I see. However, 1.6 is no longer supported. I try to support the current and previous versions of Go (while Go itself even only supports the current version). From my experience, updating Go is nowhere as critical as in other environments.

@caseyw
Copy link

caseyw commented Jun 22, 2017

Note that this bit me as well. I've updated to 1.8 and everything compiled.

Thanks,

-c

@utrack utrack deleted the v5.healthleaks branch June 30, 2017 13:01
dylannz pushed a commit to HomesNZ/elastic that referenced this pull request Aug 7, 2017
This is a backport of olivere#543 for elastic.v3 (see also olivere#545).
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

Successfully merging this pull request may close these issues.

None yet

4 participants