From 387d9e1801884cdfe84a9bf74e59718080372fdb Mon Sep 17 00:00:00 2001 From: lance6716 Date: Tue, 2 Feb 2021 15:23:18 +0800 Subject: [PATCH] address comment --- pkg/ha/keepalive.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/ha/keepalive.go b/pkg/ha/keepalive.go index 8da7cc6926..890e8a6be3 100644 --- a/pkg/ha/keepalive.go +++ b/pkg/ha/keepalive.go @@ -146,6 +146,7 @@ func KeepAlive(ctx context.Context, cli *clientv3.Client, workerName string, kee return nil case newTTL := <-KeepAliveUpdateCh: // create a new lease with new TTL, and overwrite original KV + oldLeaseID := leaseID leaseID, err = grantAndPutKV(k, workerEventJSON, newTTL) if err != nil { keepAliveCancel() // make go vet happy @@ -161,8 +162,13 @@ func KeepAlive(ctx context.Context, cli *clientv3.Client, workerName string, kee return err } log.L().Info("dynamically changed keepalive TTL to", zap.Int64("ttl in seconds", newTTL)) + // after new keepalive is succeed, we cancel the old keepalive oldCancel() + _, err2 := revokeLease(cli, oldLeaseID) + if err2 != nil { + log.L().Warn("fail to revoke lease", zap.Error(err)) + } } } }