Skip to content

Commit

Permalink
etcdmain: handle StopNotify when ErrStopped aborted publish
Browse files Browse the repository at this point in the history
Fix #7512.

If a server starts and aborts due to config error,
it is possible to get stuck in ReadyNotify waits.
This adds select case to get notified on stop channel.

Signed-off-by: Gyu-Ho Lee <[email protected]>
  • Loading branch information
gyuho committed Mar 20, 2017
1 parent 3a1368d commit 543800a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion etcdmain/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,11 @@ func startEtcd(cfg *embed.Config) (<-chan struct{}, <-chan error, error) {
return nil, nil, err
}
osutil.RegisterInterruptHandler(e.Server.Stop)
<-e.Server.ReadyNotify() // wait for e.Server to join the cluster
select {
case <-e.Server.ReadyNotify(): // wait for e.Server to join the cluster
case <-e.Server.StopNotify(): // publish aborted from 'ErrStopped'
e.Server.HardStop()
}
return e.Server.StopNotify(), e.Err(), nil
}

Expand Down

0 comments on commit 543800a

Please sign in to comment.