From 6b9338c74c3a7a0be936ee46b5c456d4bd14ae4e Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Wed, 14 Jun 2017 12:54:50 -0700 Subject: [PATCH] lease: rate limit revoke runLoop Fix https://github.com/coreos/etcd/issues/8097. Signed-off-by: Gyu-Ho Lee --- lease/lessor.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lease/lessor.go b/lease/lessor.go index 5120d1cfcdd3..eb489fb092f3 100644 --- a/lease/lessor.go +++ b/lease/lessor.go @@ -31,6 +31,10 @@ import ( const ( // NoLease is a special LeaseID representing the absence of a lease. NoLease = LeaseID(0) + + // maximum number of leases to revoke per iteration + // TODO: make this configurable? + leaseRevokeRate = 1000 ) var ( @@ -422,6 +426,10 @@ func (le *lessor) runLoop() { le.mu.Unlock() if len(ls) != 0 { + // keep half for next iteration + if len(ls) > leaseRevokeRate/2 { + ls = ls[:leaseRevokeRate/2] + } select { case <-le.stopC: return