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

nsqd: ensure all Notify() goroutines have completed prior to shutdown #493

Merged
merged 1 commit into from Nov 7, 2014

Conversation

allgeek
Copy link

@allgeek allgeek commented Nov 6, 2014

This should fix #491 ... I have been unable to reproduce the fairly regular panics since adding this fix. Note that I had to register the channel/topic notifications with the root nsqd waitGroup - while the channels and topics have their own waitGroups, those are waited on during their exit() methods. Since nsqd's Exit() method owns the nsqd Lock when it closes the topics, those topics deadlock if they had to wait on any pending Notify().

Ready for review.

@mreiferson
Copy link
Member

Ok, I guess that was pretty straightforward.

My only issue is that I don't think these "children" of nsqd should be able to add things to its wait group - perhaps nsqd.Notify() needs to do the wait group accounting and then children can just call that.

Feels like a better abstraction to me. What do you think?

@allgeek
Copy link
Author

allgeek commented Nov 7, 2014

I've updated the PR with the cleaner abstraction; thanks for the feedback - still getting used to a language with minimal access levels / just package-level encapsulation :) I also incorporated Jehiah's suggestion for the temp file name randomization mentioned in #491 per our discussion in IRC yesterday.

Ready for review again.

@mreiferson
Copy link
Member

LGTM, want to squash?

… and prevent possible atomic_rename panics in Windows test suite

* channel and topic changes now call nsqd.Notify() syncrhonously, and nsqd is responsible for spawning goroutines that will be tracked in its waitGroup for completion prior to exit.
* nsqd's PersistMetadata uses a random temp filename to reduce the risk of concurrent tests stepping on each other
@allgeek allgeek force-pushed the windows_atomic_rename_panic_491 branch from 4f178d3 to b8c74b1 Compare November 7, 2014 22:36
@allgeek
Copy link
Author

allgeek commented Nov 7, 2014

Squashed! Ready for review (hopefully for good this time!)

@mreiferson
Copy link
Member

nice work, thanks @allgeek

mreiferson added a commit that referenced this pull request Nov 7, 2014
nsqd: ensure all Notify() goroutines have completed prior to shutdown
@mreiferson mreiferson merged commit 78be50f into nsqio:master Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nsqd: intermittent atomic_rename() panic when testing on Windows
2 participants