Raft: re-enable: do not start with unconsistent peers.
Improved error messages License: MIT Signed-off-by: Hector Sanjuan <hector@protocol.ai>
This commit is contained in:
parent
74ed634653
commit
10c7afbd59
|
@ -1230,10 +1230,11 @@ func (c *Cluster) backupState() {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
err = c.state.Snapshot(f)
|
err = c.state.Snapshot(f)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(err)
|
logger.Error(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer f.Close()
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,10 @@ import (
|
||||||
p2praft "github.com/libp2p/go-libp2p-raft"
|
p2praft "github.com/libp2p/go-libp2p-raft"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ErrBadRaftState is returned when the consensus component cannot start
|
||||||
|
// because the cluster peers do not match the raft peers.
|
||||||
|
var ErrBadRaftState = errors.New("cluster peers do not match raft peers")
|
||||||
|
|
||||||
// RaftMaxSnapshots indicates how many snapshots to keep in the consensus data
|
// RaftMaxSnapshots indicates how many snapshots to keep in the consensus data
|
||||||
// folder.
|
// folder.
|
||||||
// TODO: Maybe include this in Config. Not sure how useful it is to touch
|
// TODO: Maybe include this in Config. Not sure how useful it is to touch
|
||||||
|
@ -135,18 +139,22 @@ func newRaftWrapper(peers []peer.ID, host host.Host, cfg *Config, fsm hraft.FSM)
|
||||||
added, removed := diffConfigurations(srvCfg, currentCfg)
|
added, removed := diffConfigurations(srvCfg, currentCfg)
|
||||||
if len(added)+len(removed) > 0 {
|
if len(added)+len(removed) > 0 {
|
||||||
raftW.Shutdown()
|
raftW.Shutdown()
|
||||||
logger.Warning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
logger.Error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||||
logger.Warning("Raft peers do not match cluster peers from the configuration.")
|
logger.Error("Raft peers do not match cluster peers from the configuration.")
|
||||||
logger.Warning("If problems arise, clean this peer and bootstrap it to a working cluster.")
|
logger.Error("This likely indicates that this peer has left the cluster and/or")
|
||||||
logger.Warning("Raft peers:")
|
logger.Error("has a dirty state. Clean the raft state for this peer")
|
||||||
|
logger.Error("(%s)", dataFolder)
|
||||||
|
logger.Error("bootstrap it to a working cluster.")
|
||||||
|
logger.Error("Raft peers:")
|
||||||
for _, s := range currentCfg.Servers {
|
for _, s := range currentCfg.Servers {
|
||||||
logger.Warningf(" - %s", s.ID)
|
logger.Errorf(" - %s", s.ID)
|
||||||
}
|
}
|
||||||
logger.Warning("Cluster configuration peers:")
|
logger.Error("Cluster configuration peers:")
|
||||||
for _, s := range srvCfg.Servers {
|
for _, s := range srvCfg.Servers {
|
||||||
logger.Warningf(" - %s", s.ID)
|
logger.Errorf(" - %s", s.ID)
|
||||||
}
|
}
|
||||||
logger.Warningf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
logger.Errorf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||||
|
return nil, ErrBadRaftState
|
||||||
//return nil, errors.New("Bad cluster peers")
|
//return nil, errors.New("Bad cluster peers")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user