-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lease: rate limit revoke runLoop #8099
Conversation
1a5f816
to
cc9f075
Compare
etcdserver/server.go
Outdated
} | ||
revokerLimiter.Wait(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use c.ctx
instead of the context.Background()
? and if Wait
returns an error, how should we handle it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait
won't never return error if we pass Background
, unless we mis-configure in the beginning
etcdserver/server.go
Outdated
} | ||
revokerLimiter.Wait(context.Background()) | ||
lid := lease.ID | ||
s.goAttach(func() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxPendingRevokes
is designed to take at most maxPendingRevokes
(16 in this case) lease revoke at same time. By removing that, it means that there can be 1000 go routines that revoking the lease at the same time. Is that fine? I think the original design was to limit number of simultaneous revokes call to etcd.
etcdserver/server.go
Outdated
maxPendingRevokes = 16 | ||
// TODO: make this configurable? | ||
// maximum number of leases to revoke per second | ||
leaseRevokeRate = 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leaseRevokesPerSecond
?
etcdserver/server.go
Outdated
} | ||
revokerLimiter.Wait(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this rate limiting probably belongs in lessor.runLoop
instead of the etcd server
cc9f075
to
1e5a8ac
Compare
lease/lessor.go
Outdated
@@ -412,7 +419,8 @@ func (le *lessor) Stop() { | |||
func (le *lessor) runLoop() { | |||
defer close(le.doneC) | |||
|
|||
for { | |||
revokerLimiter := rate.NewLimiter(rate.Limit(leaseRevokesPerSecond), leaseRevokesPerSecond) | |||
for revokerLimiter.Wait(context.Background()) == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this will work since findExpiredLeases
can give len(ls) > leaseRevokesPerSecond
. Maybe just have something like if len(ls) > leaseRevokesPerSecond/2 { ls = ls[:leaseRevokesPerSecond/2]}
before posting to expiredC
?
515ee34
to
6b9338c
Compare
lease/lessor.go
Outdated
@@ -422,6 +426,10 @@ func (le *lessor) runLoop() { | |||
le.mu.Unlock() | |||
|
|||
if len(ls) != 0 { | |||
// keep half for next iteration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// rate limit
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm thanks
Fix etcd-io#8097. Signed-off-by: Gyu-Ho Lee <[email protected]>
6b9338c
to
0011b78
Compare
lgtm |
Fix #8097.