Browse Source
Merge pull request #2885 from binbinshi/master
fix: master lose some volumes
pull/2888/head
Chris Lu
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
17 additions and
1 deletions
-
weed/server/master_grpc_server.go
-
weed/topology/topology.go
-
weed/topology/topology_event_handling.go
|
|
@ -113,6 +113,9 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ |
|
|
|
} |
|
|
|
|
|
|
|
if len(heartbeat.Volumes) > 0 || heartbeat.HasNoVolumes { |
|
|
|
dcName, rackName := ms.Topo.Configuration.Locate(heartbeat.Ip, heartbeat.DataCenter, heartbeat.Rack) |
|
|
|
ms.Topo.DataNodeRegistration(dcName, rackName, dn) |
|
|
|
|
|
|
|
// process heartbeat.Volumes
|
|
|
|
stats.MasterReceivedHeartbeatCounter.WithLabelValues("Volumes").Inc() |
|
|
|
newVolumes, deletedVolumes := ms.Topo.SyncDataNodeRegistration(heartbeat.Volumes, dn) |
|
|
|
|
|
@ -283,3 +283,14 @@ func (t *Topology) IncrementalSyncDataNodeRegistration(newVolumes, deletedVolume |
|
|
|
|
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
func (t *Topology) DataNodeRegistration(dcName, rackName string ,dn *DataNode){ |
|
|
|
if dn.Parent() != nil{ |
|
|
|
return |
|
|
|
} |
|
|
|
// registration to topo
|
|
|
|
dc := t.GetOrCreateDataCenter(dcName) |
|
|
|
rack := dc.GetOrCreateRack(rackName) |
|
|
|
rack.LinkChildNode(dn) |
|
|
|
glog.Infof("[%s] reLink To topo ", dn.Id()) |
|
|
|
} |
|
|
@ -1,6 +1,7 @@ |
|
|
|
package topology |
|
|
|
|
|
|
|
import ( |
|
|
|
"github.com/chrislusf/seaweedfs/weed/storage/erasure_coding" |
|
|
|
"github.com/chrislusf/seaweedfs/weed/storage/types" |
|
|
|
"google.golang.org/grpc" |
|
|
|
"math/rand" |
|
|
@ -84,7 +85,8 @@ func (t *Topology) UnRegisterDataNode(dn *DataNode) { |
|
|
|
|
|
|
|
negativeUsages := dn.GetDiskUsages().negative() |
|
|
|
dn.UpAdjustDiskUsageDelta(negativeUsages) |
|
|
|
|
|
|
|
dn.DeltaUpdateVolumes([]storage.VolumeInfo{}, dn.GetVolumes()) |
|
|
|
dn.DeltaUpdateEcShards([]*erasure_coding.EcVolumeInfo{}, dn.GetEcShards()) |
|
|
|
if dn.Parent() != nil { |
|
|
|
dn.Parent().UnlinkChildNode(dn.Id()) |
|
|
|
} |
|
|
|