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

meter: once all meters are stopped, reset arbiter #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdef
Copy link

@jdef jdef commented Aug 15, 2018

There's a background goroutine that always runs once a single (non-nil) meter has been added to the system. Even if that meter stops, the background goroutine continues to run. This confuses unit and component tests that check for goroutine leakage. Until this PR, there was no way to terminate the background (arbiter) goroutine created by this package.

With the introduction of this change, once all known meters have been stopped the arbiter is "reset" and the background goroutine terminated.

An example of a popular goroutine leak checker: https://github.com/fortytw2/leaktest

@jdef
Copy link
Author

jdef commented Aug 15, 2018

hrm .. this is racy. going to mark as WIP for now

@jdef jdef changed the title meter: once all meters are stopped, reset arbiter [[--WIP--]] meter: once all meters are stopped, reset arbiter Aug 15, 2018
@jdef
Copy link
Author

jdef commented Aug 15, 2018

forced-pushed a fix for the race

@jdef jdef changed the title [[--WIP--]] meter: once all meters are stopped, reset arbiter meter: once all meters are stopped, reset arbiter Aug 15, 2018
@jdef
Copy link
Author

jdef commented Aug 15, 2018

Looks like CI flaked out. I don't see an option to restart the failed build.

@mihasya
Copy link
Collaborator

mihasya commented Aug 27, 2018

Took me a really long time to find the "rebuild" button because it's just hidden when you're not logged in 🤦‍♂️ . Let's see if it succeeds on second try.

@jdef
Copy link
Author

jdef commented Aug 29, 2018

@mihasya thanks for the rebuild. Does this like something worth landing on master?

@jdef
Copy link
Author

jdef commented Sep 27, 2018

PTAL, would love to avoid maintaining a fork for this

@mihasya
Copy link
Collaborator

mihasya commented Sep 27, 2018 via email

@mihasya
Copy link
Collaborator

mihasya commented Oct 16, 2018

@jdef I think both this patch and #246 updated the .Stop logic to use CAS, so now there's a conflict. It's probably a very simple rebase. Would you mind giving it a go? Thank you, and sorry about the trouble.

@jdef
Copy link
Author

jdef commented Oct 23, 2018

Rebased

@jdef
Copy link
Author

jdef commented Oct 23, 2018

@mihasya PTAL

1 similar comment
@jdef
Copy link
Author

jdef commented Nov 12, 2018

@mihasya PTAL

@mihasya
Copy link
Collaborator

mihasya commented Nov 13, 2018 via email

@jdef
Copy link
Author

jdef commented Dec 6, 2018

@mihasya @wadey @rcrowley PTAL

@mihasya
Copy link
Collaborator

mihasya commented Dec 6, 2018

Today's the day. Got one small question, otherwise should be good. Thank you for your patience.

@jdef
Copy link
Author

jdef commented Dec 6, 2018

OK @mihasya, what's your question?

@mihasya
Copy link
Collaborator

mihasya commented Dec 6, 2018 via email

@jdef
Copy link
Author

jdef commented Jan 11, 2019

@mihasya I don't see any additional comments. Mind taking a few seconds to re-review this change?

@jdef
Copy link
Author

jdef commented Mar 19, 2019

@mihasya PTAL

1 similar comment
@jdef
Copy link
Author

jdef commented May 21, 2019

@mihasya PTAL

}

var arbiter = meterArbiter{ticker: time.NewTicker(5e9), meters: make(map[*StandardMeter]struct{})}

// Ticks meters on the scheduled interval
func (ma *meterArbiter) tick() {
func (ma *meterArbiter) tick(ticker *time.Ticker, cancel <-chan struct{}) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why make ticker out as its own argument rather than just referring to the member ticker? Seems like everywhere this is used, it's just calling ma.ticker.

@mihasya
Copy link
Collaborator

mihasya commented Jul 4, 2019

@jdef I just realized why you weren't seeing my comment - I made a comment as part of a "review" but didn't click "Submit Review" - so it showed up as part of the PR thread when I looked at it, but not you 🤦‍♂

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

2 participants