Embed: In case KVStoreHash verification fails, close the backend.

In case of failed verification, the server used to keep opened backend
(so the file was locked on OS level).
This commit is contained in:
Piotr Tabor
2021-04-29 01:03:36 +02:00
parent 2ad893b110
commit f53b70facb
6 changed files with 48 additions and 26 deletions

View File

@@ -229,6 +229,9 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
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.cfg.logger.Error("checkInitialHashKV failed", zap.Error(err))
e.Server.Cleanup()
e.Server = nil
return e, err
}