Browse Source

reduce the window size between unregistering a volume server and creating volumes on that server

fix https://github.com/seaweedfs/seaweedfs/issues/4467
pull/4527/head
chrislu 2 years ago
parent
commit
ca7cc61319
  1. 1
      weed/topology/data_node.go
  2. 6
      weed/topology/node.go
  3. 1
      weed/topology/topology_event_handling.go

1
weed/topology/data_node.go

@ -20,6 +20,7 @@ type DataNode struct {
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 Counter int // in race condition, the previous dataNode was not dead
IsTerminating bool
} }
func NewDataNode(id string) *DataNode { func NewDataNode(id string) *DataNode {

6
weed/topology/node.go

@ -179,7 +179,11 @@ func (n *NodeImpl) ReserveOneVolume(r int64, option *VolumeGrowOption) (assigned
} else { } else {
if node.IsDataNode() && node.AvailableSpaceFor(option) > 0 { if node.IsDataNode() && node.AvailableSpaceFor(option) > 0 {
// fmt.Println("vid =", vid, " assigned to node =", node, ", freeSpace =", node.FreeSpace()) // fmt.Println("vid =", vid, " assigned to node =", node, ", freeSpace =", node.FreeSpace())
return node.(*DataNode), nil
dn := node.(*DataNode)
if dn.IsTerminating {
continue
}
return dn, nil
} }
assignedNode, err = node.ReserveOneVolume(r, option) assignedNode, err = node.ReserveOneVolume(r, option)
if err == nil { if err == nil {

1
weed/topology/topology_event_handling.go

@ -82,6 +82,7 @@ func (t *Topology) SetVolumeCrowded(volumeInfo storage.VolumeInfo) {
} }
func (t *Topology) UnRegisterDataNode(dn *DataNode) { func (t *Topology) UnRegisterDataNode(dn *DataNode) {
dn.IsTerminating = true
for _, v := range dn.GetVolumes() { for _, v := range dn.GetVolumes() {
glog.V(0).Infoln("Removing Volume", v.Id, "from the dead volume server", dn.Id()) glog.V(0).Infoln("Removing Volume", v.Id, "from the dead volume server", dn.Id())
diskType := types.ToDiskType(v.DiskType) diskType := types.ToDiskType(v.DiskType)

Loading…
Cancel
Save