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

Move autopilot initialization to prevent race #5322

Merged
merged 1 commit into from
Feb 11, 2019
Merged

Conversation

mkeeler
Copy link
Member

@mkeeler mkeeler commented Feb 6, 2019

establishLeadership invoked during leadership monitoring may use autopilot to do promotions etc. There was a race with doing that and having autopilot initialized and this fixes it.

`establishLeadership` invoked during leadership monitoring may use autopilot to do promotions etc. There was a race with doing that and having autopilot initialized and this fixes it.
@mkeeler mkeeler added this to the 1.4.3 milestone Feb 6, 2019
@mkeeler mkeeler requested a review from a team February 6, 2019 21:54
@hanshasselberg
Copy link
Member

I was curious what exactly happens. monitorLeadership starts leaderLoop:

leaderLoop.Add(1)
go func(ch chan struct{}) {
defer leaderLoop.Done()
s.leaderLoop(ch)
}(weAreLeaderCh)

And in leaderLoop we call establishLeadership:

if err := s.establishLeadership(); err != nil {

Which finally tries to use autopilot:

s.autopilot.Start()

Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

👍

@mkeeler mkeeler merged commit 7073ba4 into master Feb 11, 2019
@mkeeler mkeeler deleted the bugfix/autopilot-race branch March 4, 2019 18:56
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.

3 participants