Skip to content

Commit

Permalink
embed: corrupt-check on restart member
Browse files Browse the repository at this point in the history
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Nov 23, 2017
1 parent c2149c5 commit f7816fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions embed/etcd.go
Expand Up @@ -124,7 +124,9 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
token string
)

memberInitialized := true
if !isMemberInitialized(cfg) {
memberInitialized = false
urlsmap, token, err = cfg.PeerURLsMapAndToken("etcd")
if err != nil {
return e, fmt.Errorf("error setting up initial cluster: %v", err)
Expand Down Expand Up @@ -186,6 +188,16 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
// buffer channel so goroutines on closed connections won't wait forever
e.errc = make(chan error, len(e.Peers)+len(e.Clients)+2*len(e.sctxs))

// newly started member ("memberInitialized==false")
// does not need corruption check
if memberInitialized {
if err = e.Server.CheckInitialHashKV(); err != nil {
// set "EtcdServer" to nil, so that it does not block on "EtcdServer.Close()"
// (nothing to close since rafthttp transports have not been started)
e.Server = nil
return e, err
}
}
e.Server.Start()

if err = e.servePeers(); err != nil {
Expand Down

0 comments on commit f7816fd

Please sign in to comment.