mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: close mvcc.KV on init error path
Scheduled compaction will panic if KV is not stopped before closing the backend.
This commit is contained in:
parent
f75e333264
commit
c1c9a2c96c
@ -450,6 +450,15 @@ func NewServer(cfg *ServerConfig) (srv *EtcdServer, err error) {
|
|||||||
plog.Warningf("consistent index never saved (snapshot index=%d)", snapshot.Metadata.Index)
|
plog.Warningf("consistent index never saved (snapshot index=%d)", snapshot.Metadata.Index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
newSrv := srv // since srv == nil in defer if srv is returned as nil
|
||||||
|
defer func() {
|
||||||
|
// closing backend without first closing kv can cause
|
||||||
|
// resumed compactions to fail with closed tx errors
|
||||||
|
if err != nil {
|
||||||
|
newSrv.kv.Close()
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
|
srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
|
||||||
tp, err := auth.NewTokenProvider(cfg.AuthToken,
|
tp, err := auth.NewTokenProvider(cfg.AuthToken,
|
||||||
func(index uint64) <-chan struct{} {
|
func(index uint64) <-chan struct{} {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user