Fix goroutine leak in consulcatalog when consul is down#3036
Merged
traefiker merged 1 commit intotraefik:v1.5from Mar 20, 2018
Merged
Fix goroutine leak in consulcatalog when consul is down#3036traefiker merged 1 commit intotraefik:v1.5from
traefiker merged 1 commit intotraefik:v1.5from
Conversation
juliens
requested changes
Mar 19, 2018
Member
There was a problem hiding this comment.
Why not add 1 buffer on this chan instead of the sync.Once?
Contributor
Author
There was a problem hiding this comment.
Adding buffers will reduce maintainability because a number of capacity is depended on the number of gorountines which spawned at other functions. By using sync.Once, it will no longer need to worry about thinking the number of the buffer and blocking of the channel.
Member
There was a problem hiding this comment.
ok for me.
We need this bug fix in 1.5, can you do this PR on branch v1.5 ?
Contributor
Author
There was a problem hiding this comment.
Changed base branch to v1.5 and patched the fix to it.
1b0a516 to
c1eadef
Compare
c060335 to
2c3640a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fix goroutine leaks in consulcatalog provider. Use
sync.Onceto avoid blocking when sending errors to the channel which already used and an owner function of it is already exited.Below is a number of goroutines by metrics data.
(traefik command is
./dist/traefik --consulcatalog --entryPoints=Name:http Address::18080 --web.address=:10080 --web.metrics --web.metrics.prometheus --web.metrics.prometheus.entrypoint=traefik, andconsulis not started)Motivation
Assume there are 2 goroutines are spawned and they have the same error channel. If one goroutine sends an error to the channel, the caller returns by getting an error from the channel. Then the other goroutine will stuck when also trying to send an error to the channel because an owner of the error channel is already exited.
Additional Notes