Skip to content

Commit

Permalink
lease: rate limit revoke runLoop
Browse files Browse the repository at this point in the history
Fix #8097.

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
  • Loading branch information
gyuho committed Jun 14, 2017
1 parent e6d2667 commit 515ee34
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lease/lessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?
leaseRevokesRate = 1000
)

var (
Expand Down Expand Up @@ -422,6 +426,10 @@ func (le *lessor) runLoop() {
le.mu.Unlock()

if len(ls) != 0 {
// keep half for next iteration
if len(ls) > leaseRevokesRate/2 {
ls = ls[:leaseRevokesRate/2]
}
select {
case <-le.stopC:
return
Expand Down

0 comments on commit 515ee34

Please sign in to comment.