mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: recover lessor when applying snapshot
This commit is contained in:
parent
6a3e8d4bde
commit
adcba975cb
@ -616,6 +616,10 @@ func (s *EtcdServer) applySnapshot(ep *etcdProgress, apply *apply) {
|
||||
|
||||
s.be = newbe
|
||||
s.bemu.Unlock()
|
||||
|
||||
if s.lessor != nil {
|
||||
s.lessor.Recover(s.be, s.kv)
|
||||
}
|
||||
}
|
||||
if err := s.store.Recovery(apply.snapshot.Data); err != nil {
|
||||
plog.Panicf("recovery store error: %v", err)
|
||||
|
@ -93,6 +93,9 @@ type Lessor interface {
|
||||
// ExpiredLeasesC returns a chan that is used to receive expired leases.
|
||||
ExpiredLeasesC() <-chan []*Lease
|
||||
|
||||
// Recover recovers the lessor state from the given backend and RangeDeleter.
|
||||
Recover(b backend.Backend, rd RangeDeleter)
|
||||
|
||||
// Stop stops the lessor for managing leases. The behavior of calling Stop multiple
|
||||
// times is undefined.
|
||||
Stop()
|
||||
@ -476,8 +479,7 @@ func int64ToBytes(n int64) []byte {
|
||||
|
||||
// FakeLessor is a fake implementation of Lessor interface.
|
||||
// Used for testing only.
|
||||
type FakeLessor struct {
|
||||
}
|
||||
type FakeLessor struct{}
|
||||
|
||||
func (fl *FakeLessor) SetRangeDeleter(dr RangeDeleter) {}
|
||||
|
||||
@ -499,4 +501,6 @@ func (le *FakeLessor) Lookup(id LeaseID) *Lease { return nil }
|
||||
|
||||
func (fl *FakeLessor) ExpiredLeasesC() <-chan []*Lease { return nil }
|
||||
|
||||
func (fl *FakeLessor) Recover(b backend.Backend, rd RangeDeleter) {}
|
||||
|
||||
func (fl *FakeLessor) Stop() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user