From 855d4929c1b7779b72dfd01f00e123419b6df47b Mon Sep 17 00:00:00 2001 From: tangcong Date: Sun, 29 Mar 2020 08:09:46 +0800 Subject: [PATCH] lease: fix memory leak in LeaseGrant when node is follower --- lease/lessor.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lease/lessor.go b/lease/lessor.go index cc20283167ea..c036e5d82354 100644 --- a/lease/lessor.go +++ b/lease/lessor.go @@ -291,14 +291,14 @@ func (le *lessor) Grant(id LeaseID, ttl int64) (*Lease, error) { } le.leaseMap[id] = l - item := &LeaseWithTime{id: l.ID, time: l.expiry.UnixNano()} - le.leaseExpiredNotifier.RegisterOrUpdate(item) l.persistTo(le.b) leaseTotalTTLs.Observe(float64(l.ttl)) leaseGranted.Inc() if le.isPrimary() { + item := &LeaseWithTime{id: l.ID, time: l.expiry.UnixNano()} + le.leaseExpiredNotifier.RegisterOrUpdate(item) le.scheduleCheckpointIfNeeded(l) }