mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
etcdserver: truncate WAL from correct index when forcing new cluster
When loading from a backup with a snapshot and WAL, the length of WAL entries can be lower than the current index integer value, causing a panic when slicing off uncommitted entries. This looks for WAL entries higher than the current index before slicing.
This commit is contained in:
parent
e3cb3d640b
commit
c67b937d62
@ -33,8 +33,12 @@ func restartAsStandaloneNode(cfg *ServerConfig, index uint64, snapshot *raftpb.S
|
|||||||
cfg.Cluster.SetID(cid)
|
cfg.Cluster.SetID(cid)
|
||||||
|
|
||||||
// discard the previously uncommitted entries
|
// discard the previously uncommitted entries
|
||||||
if len(ents) != 0 {
|
for i, ent := range ents {
|
||||||
ents = ents[:st.Commit+1]
|
if ent.Index > st.Commit {
|
||||||
|
log.Printf("etcdserver: discarding %d uncommited WAL entries ", len(ents)-i)
|
||||||
|
ents = ents[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// force append the configuration change entries
|
// force append the configuration change entries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user