Skip to content

Conversation

@oliver006
Copy link
Contributor

Unfortunately, refreshTicker.Stop() doesn't close the refreshTicker channel so the goroutines refreshing the node status don't ever exit and goroutines start accumulating every time you open a new session to a cluster.
This PR changes the code to use a bool chan instead of the ticker channel.

@dancannon
Copy link
Collaborator

Thanks for spotting this issue, leaking goroutines can be as easy as creating them! What do you think of just doing something like this instead?

n.refreshTicker.Stop()
close(n.refreshTicker.C)

@oliver006
Copy link
Contributor Author

Yeah, that was my first thought as well but turns out, you can't close the ticker channel, it's read-only.
See http://stackoverflow.com/questions/17797754/ticker-stop-behaviour-in-golang for details.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could use a chan struct{} here instead. Not much difference but theres no reason not to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Kinda the same but I slightly prefer the bool chan as it somewhat better communicates the Done == true fact. No strong feelings though.

@dancannon
Copy link
Collaborator

Oh interesting, I will give it a proper test tomorrow then. Thanks.

@oliver006
Copy link
Contributor Author

Sounds good.

@oliver006
Copy link
Contributor Author

fyi, ran this with the fixed version for a while, you can spot the difference quite easily:

screen shot 2015-04-18 at 7 12 40 pm

dancannon added a commit that referenced this pull request Apr 19, 2015
Use channel to stop the node.Refresh() goroutine
@dancannon dancannon merged commit ab252a5 into rethinkdb:master Apr 19, 2015
@kofalt
Copy link

kofalt commented Apr 20, 2015

@oliver006 Pardon the intrusion - what user interface is that screenshot from?

@oliver006
Copy link
Contributor Author

@kofalt - no worries. The data is collected via Prometheus and the UI is PromDash
I wrote a rethinkdb metrics exporter for Prometheus which you can find here if you're interested: https://github.com/oliver006/rethinkdb_exporter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants