Skip to content
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

refactor server code and bugfix #19

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Election bugfix (#3)
* Refactor rate limiter code and add inflight rate limiter

* InFlightRateLimiter: take ctx.Done into consideration and bug fix

* etcdElection:  bug fix, client retry should sleep interval
  • Loading branch information
BlueBlue-Lee committed Dec 4, 2017
commit 228f7494c668fced09492663de753f60540f5d7f
15 changes: 8 additions & 7 deletions go/server/election/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,19 @@ func (e *etcdElection) campaignAndRenew(ctx context.Context, id string) {
for {
time.Sleep(e.lease / 5)
log.V(2).Infof("Renewing mastership lease at %v as %v", e.lock, id)
_, err := e.client.Set(ctx, e.lock, id, &client.SetOptions{
TTL: e.lease,
PrevExist: client.PrevExist,
PrevValue: id,
})

for retry := 0; retry < 2; retry++ {
var err error
for retry := 0; retry < 3; retry++ {
_, err = e.client.Set(ctx, e.lock, id, &client.SetOptions{
TTL: e.lease,
PrevExist: client.PrevExist,
PrevValue: id,
})

if err != nil {
time.Sleep(e.lease / 5)
} else {
break
}
}

if err != nil {
Expand Down