mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #17151 from serathius/fix-bootstrap
[release-3.5] Fix etcd bootstrap: Etcd not validating database consistent index, closing database and panicking on nil backend.
This commit is contained in:
commit
ae3b43a924
@ -35,6 +35,7 @@ import (
|
|||||||
humanize "github.com/dustin/go-humanize"
|
humanize "github.com/dustin/go-humanize"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"go.etcd.io/etcd/server/v3/config"
|
"go.etcd.io/etcd/server/v3/config"
|
||||||
|
"go.etcd.io/etcd/server/v3/wal/walpb"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
|
||||||
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
|
pb "go.etcd.io/etcd/api/v3/etcdserverpb"
|
||||||
@ -392,7 +393,7 @@ func NewServer(cfg config.ServerConfig) (srv *EtcdServer, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if be != nil && err != nil {
|
||||||
be.Close()
|
be.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -485,13 +486,14 @@ func NewServer(cfg config.ServerConfig) (srv *EtcdServer, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find a snapshot to start/restart a raft node
|
// Find a snapshot to start/restart a raft node
|
||||||
walSnaps, err := wal.ValidSnapshotEntries(cfg.Logger, cfg.WALDir())
|
var walSnaps []walpb.Snapshot
|
||||||
|
walSnaps, err = wal.ValidSnapshotEntries(cfg.Logger, cfg.WALDir())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// snapshot files can be orphaned if etcd crashes after writing them but before writing the corresponding
|
// snapshot files can be orphaned if etcd crashes after writing them but before writing the corresponding
|
||||||
// wal log entries
|
// wal log entries
|
||||||
snapshot, err := ss.LoadNewestAvailable(walSnaps)
|
snapshot, err = ss.LoadNewestAvailable(walSnaps)
|
||||||
if err != nil && err != snap.ErrNoSnapshot {
|
if err != nil && err != snap.ErrNoSnapshot {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user