From 5496d68f6a633f10e821cf7d7b319e773231aaa8 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 11 Sep 2021 02:05:55 -0700 Subject: [PATCH] increase counter only if not early terminated --- weed/server/master_grpc_server.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/weed/server/master_grpc_server.go b/weed/server/master_grpc_server.go index 80cd37879..2cd9ef4a4 100644 --- a/weed/server/master_grpc_server.go +++ b/weed/server/master_grpc_server.go @@ -50,7 +50,6 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ } ms.clientChansLock.RUnlock() } - } }() @@ -72,14 +71,14 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ dc := ms.Topo.GetOrCreateDataCenter(dcName) rack := dc.GetOrCreateRack(rackName) dn = rack.GetOrCreateDataNode(heartbeat.Ip, int(heartbeat.Port), heartbeat.PublicUrl, heartbeat.MaxVolumeCounts) - dn.Counter++ - glog.V(0).Infof("added volume server %v:%d", heartbeat.GetIp(), heartbeat.GetPort()) + glog.V(0).Infof("added %d volume server %v:%d", dn.Counter, heartbeat.GetIp(), heartbeat.GetPort()) if err := stream.Send(&master_pb.HeartbeatResponse{ VolumeSizeLimit: uint64(ms.option.VolumeSizeLimitMB) * 1024 * 1024, }); err != nil { glog.Warningf("SendHeartbeat.Send volume size to %s:%d %v", dn.Ip, dn.Port, err) return err } + dn.Counter++ } dn.AdjustMaxVolumeCounts(heartbeat.MaxVolumeCounts)