|
@@ -395,6 +395,9 @@ func NewServer(cfg *ServerConfig) (srv *EtcdServer, err error) {
|
|
|
|
|
|
|
|
srv.be = be
|
|
srv.be = be
|
|
|
minTTL := time.Duration((3*cfg.ElectionTicks)/2) * time.Duration(cfg.TickMs) * time.Millisecond
|
|
minTTL := time.Duration((3*cfg.ElectionTicks)/2) * time.Duration(cfg.TickMs) * time.Millisecond
|
|
|
|
|
+
|
|
|
|
|
+ // always recover lessor before kv. When we recover the mvcc.KV it will reattach keys to its leases.
|
|
|
|
|
+ // If we recover mvcc.KV first, it will attach the keys to the wrong lessor before it recovers.
|
|
|
srv.lessor = lease.NewLessor(srv.be, int64(math.Ceil(minTTL.Seconds())))
|
|
srv.lessor = lease.NewLessor(srv.be, int64(math.Ceil(minTTL.Seconds())))
|
|
|
srv.kv = mvcc.New(srv.be, srv.lessor, &srv.consistIndex)
|
|
srv.kv = mvcc.New(srv.be, srv.lessor, &srv.consistIndex)
|
|
|
if beExist {
|
|
if beExist {
|
|
@@ -404,6 +407,7 @@ func NewServer(cfg *ServerConfig) (srv *EtcdServer, err error) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
|
|
srv.consistIndex.setConsistentIndex(srv.kv.ConsistentIndex())
|
|
|
|
|
+
|
|
|
srv.authStore = auth.NewAuthStore(srv.be)
|
|
srv.authStore = auth.NewAuthStore(srv.be)
|
|
|
if h := cfg.AutoCompactionRetention; h != 0 {
|
|
if h := cfg.AutoCompactionRetention; h != 0 {
|
|
|
srv.compactor = compactor.NewPeriodic(h, srv.kv, srv)
|
|
srv.compactor = compactor.NewPeriodic(h, srv.kv, srv)
|
|
@@ -660,6 +664,8 @@ func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
|
|
|
|
|
|
|
|
newbe := backend.NewDefaultBackend(fn)
|
|
newbe := backend.NewDefaultBackend(fn)
|
|
|
|
|
|
|
|
|
|
+ // always recover lessor before kv. When we recover the mvcc.KV it will reattach keys to its leases.
|
|
|
|
|
+ // If we recover mvcc.KV first, it will attach the keys to the wrong lessor before it recovers.
|
|
|
if s.lessor != nil {
|
|
if s.lessor != nil {
|
|
|
plog.Info("recovering lessor...")
|
|
plog.Info("recovering lessor...")
|
|
|
s.lessor.Recover(newbe, s.kv)
|
|
s.lessor.Recover(newbe, s.kv)
|