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

lease: ensure grant/revoke won't be applied repeatedly after restarting etcd #11935

Merged
merged 2 commits into from
May 31, 2020

Conversation

tangcong
Copy link
Contributor

Consider the following scenario:

etcdctl lease grant 10
lease 3269723c5a733e05 granted with TTL(10s)
etcdctl lease grant 15
lease 3269723c5a733e07 granted with TTL(15s)
restart etcd

we can see some error log:

20:27:54 etcd1 | {"level":"warn","ts":"2020-05-22T20:27:54.599+0800","caller":"etcdserver/util.go:120","msg":"failed to apply request","took":"35.702µs","request":"header:<ID:3632560177992121862 > lease_grant:<ttl:10-second id:3269723c5a733e05>","response":"size:0","error":"lease already exists"}
20:27:54 etcd1 | {"level":"warn","ts":"2020-05-22T20:27:54.599+0800","caller":"etcdserver/util.go:120","msg":"failed to apply request","took":"5.126µs","request":"header:<ID:3632560177992121864 > lease_grant:<ttl:15-second id:3269723c5a733e07>","response":"size:0","error":"lease already exists"}

this pr make sure that lease grant and revoke can only be executed once under any circumstances.

@tangcong
Copy link
Contributor Author

@jingyih @gyuho Please take a look. Thanks

Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thx for the improvements!

@gyuho gyuho merged commit 8af52dc into etcd-io:master May 31, 2020
@@ -523,7 +523,9 @@ func NewServer(cfg ServerConfig) (srv *EtcdServer, err error) {
MinLeaseTTL: int64(math.Ceil(minTTL.Seconds())),
CheckpointInterval: cfg.LeaseCheckpointInterval,
ExpiredLeasesRetryInterval: srv.Cfg.ReqTimeout(),
})
},
srv.consistIndex,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the field was an existing field, it seems naming the field consistentIndex is more intuitive.

@tangcong tangcong deleted the save-cindex-for-lease branch February 26, 2021 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants