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

Remediate a number go-routine leaks (mainly test issues) #2198

Merged
merged 1 commit into from
Mar 30, 2022

Conversation

k-wall
Copy link
Contributor

@k-wall k-wall commented Mar 30, 2022

  • NewClusterAdmin would leak a Client if Controller could not be found
  • unclosed MockBroker and Client leaks in unit tests

- NewClusterAdmin would leak a Client if Controller could not be found
- unclosed MockBroker and Client leaks in unit tests
Copy link
Collaborator

@dnwe dnwe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, these are great.

Out of interest did you catch them just through observing the leak during test runs, or by a linter or leak detector?

@dnwe dnwe merged commit e34cf6a into IBM:main Mar 30, 2022
@k-wall
Copy link
Contributor Author

k-wall commented Mar 31, 2022

it was the test failure under #2197 that prompted me to look.

I found golang/go#6705 which lead me to https://github.com/uber-go/goleak. I added a temporary TestMain added into the tests and then this approach to actually find those that leaked.

func TestMain(m *testing.M) {
	goleak.VerifyTestMain(m, goleak.IgnoreTopFunction("github.com/rcrowley/go-metrics.(*meterArbiter).tick"))
}

Having something built into the build to find goroute leaks/fail the build would be best, but this would require more work.

There were some goroutine leaks remaining that didn't have an obvious cause. I've raised a separate PR showing those remaining leaks and how I detected them.

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.

2 participants