From acfdd14f493e9b7c295104be7b28330f945bc570 Mon Sep 17 00:00:00 2001 From: liutengfei Date: Thu, 21 Nov 2024 13:44:00 +0800 Subject: [PATCH] fix: The intermittent abnormality of etcd has caused registration failure. (#3464) --- contrib/registry/etcd/registry.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/registry/etcd/registry.go b/contrib/registry/etcd/registry.go index 1a931153fe9..f5f3aabe3bc 100644 --- a/contrib/registry/etcd/registry.go +++ b/contrib/registry/etcd/registry.go @@ -168,7 +168,8 @@ func (r *Registry) heartBeat(ctx context.Context, leaseID clientv3.LeaseID, key if curLeaseID == 0 { // try to registerWithKV var retreat []int - for retryCnt := 0; retryCnt < r.opts.maxRetry; retryCnt++ { + var retryCnt int + for retryCnt = 0; retryCnt < r.opts.maxRetry; retryCnt++ { if ctx.Err() != nil { return } @@ -202,7 +203,7 @@ func (r *Registry) heartBeat(ctx context.Context, leaseID clientv3.LeaseID, key retreat = append(retreat, 1<= r.opts.maxRetry { // retry failed return }