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

Fix goroutine leak #562

Merged
merged 1 commit into from
Aug 12, 2016
Merged

Fix goroutine leak #562

merged 1 commit into from
Aug 12, 2016

Conversation

2opremio
Copy link

From weaveworks/scope#1767 (comment):

The problem is two-fold:

  • there can be two goroutines that attempt to output an item on errIn but the channel only has a capacity of one, so one of the goroutines will get stuck if the closer is invoked (i.e. we hit the <-quit branch), which is why we see one of first two goroutines appear in the goroutine dump. We fix this by increasing the errIn capacity to two.
  • the waiter is waiting for input on errs, but invoking the closer ends up terminating the top-level goroutine without outputting on errs, causing the waiter to be stuck. That is the third goroutine we see in the dumps. We fix this by a) removing the returns on <-quit, and b) setting the capacity of errs to one, so that the top-level goroutine doesn't end up blocking if there is no waiter.

@fsouza
Copy link
Owner

fsouza commented Aug 12, 2016

Nice catch, thanks!

@fsouza fsouza merged commit 071ccce into fsouza:master Aug 12, 2016
2opremio pushed a commit to weaveworks/scope that referenced this pull request Aug 15, 2016
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