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

futures can react to shutdown #390

Merged
merged 1 commit into from
Feb 27, 2020
Merged

futures can react to shutdown #390

merged 1 commit into from
Feb 27, 2020

Conversation

hanshasselberg
Copy link
Member

@hanshasselberg hanshasselberg commented Feb 26, 2020

This is implementing a very similar thing to #277 but a little bit more generalized, like suggested by @mkeeler.

Fixes #277, fixes #268.

@hanshasselberg hanshasselberg requested review from a team and schristoff February 26, 2020 16:33
Copy link
Contributor

@schristoff schristoff left a comment

Choose a reason for hiding this comment

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

LGTM 🤙

@hanshasselberg hanshasselberg merged commit 2e99741 into master Feb 27, 2020
@hanshasselberg hanshasselberg deleted the future_shutdown branch February 27, 2020 11:19
Copy link
Contributor

@notnoop notnoop left a comment

Choose a reason for hiding this comment

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

Change lgtm. have a question that can be clarified with a code comment.

@@ -146,6 +146,7 @@ func (r *Raft) takeSnapshot() (string, error) {
// We have to use the future here to safely get this information since
// it is owned by the main thread.
configReq := &configurationsFuture{}
configReq.ShutdownCh = r.shutdownCh
Copy link
Contributor

Choose a reason for hiding this comment

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

It may be nice to document when ShutdownCh needs to be set and what makes snapshotting special. I assume it's because snapshotting runs in an internal gorotouine and can run regardless of leadership. Other futures will be responded to immediately when not leader, or when raft loses leadership as a result of shutting down?

err error
errCh chan error
responded bool
ShutdownCh chan struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

very nit picky - can this field be private like the rest?

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.

The Raft.Shutdown() API can end up in a deadlock
3 participants