mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-01-18 22:43:41 +08:00
master: disconnect only the phantom volume server
fix https://github.com/chrislusf/seaweedfs/issues/2311
This commit is contained in:
parent
57a95887d2
commit
65af3cf4df
@ -22,7 +22,11 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if dn != nil {
|
if dn != nil {
|
||||||
|
dn.Counter--
|
||||||
|
if dn.Counter > 0 {
|
||||||
|
glog.V(0).Infof("disconnect phantom volume server %s:%d remaining %d", dn.Counter, dn.Ip, dn.Port)
|
||||||
|
return
|
||||||
|
}
|
||||||
// if the volume server disconnects and reconnects quickly
|
// if the volume server disconnects and reconnects quickly
|
||||||
// the unregister and register can race with each other
|
// the unregister and register can race with each other
|
||||||
ms.Topo.UnRegisterDataNode(dn)
|
ms.Topo.UnRegisterDataNode(dn)
|
||||||
@ -68,6 +72,7 @@ func (ms *MasterServer) SendHeartbeat(stream master_pb.Seaweed_SendHeartbeatServ
|
|||||||
dc := ms.Topo.GetOrCreateDataCenter(dcName)
|
dc := ms.Topo.GetOrCreateDataCenter(dcName)
|
||||||
rack := dc.GetOrCreateRack(rackName)
|
rack := dc.GetOrCreateRack(rackName)
|
||||||
dn = rack.GetOrCreateDataNode(heartbeat.Ip, int(heartbeat.Port), heartbeat.PublicUrl, heartbeat.MaxVolumeCounts)
|
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 volume server %v:%d", heartbeat.GetIp(), heartbeat.GetPort())
|
||||||
if err := stream.Send(&master_pb.HeartbeatResponse{
|
if err := stream.Send(&master_pb.HeartbeatResponse{
|
||||||
VolumeSizeLimit: uint64(ms.option.VolumeSizeLimitMB) * 1024 * 1024,
|
VolumeSizeLimit: uint64(ms.option.VolumeSizeLimitMB) * 1024 * 1024,
|
||||||
|
@ -18,6 +18,7 @@ type DataNode struct {
|
|||||||
Port int
|
Port int
|
||||||
PublicUrl string
|
PublicUrl string
|
||||||
LastSeen int64 // unix time in seconds
|
LastSeen int64 // unix time in seconds
|
||||||
|
Counter int // in race condition, the previous dataNode was not dead
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDataNode(id string) *DataNode {
|
func NewDataNode(id string) *DataNode {
|
||||||
|
Loading…
Reference in New Issue
Block a user