aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_tier_move.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-08-10 04:13:08 -0700
committerChris Lu <chris.lu@gmail.com>2021-08-10 04:13:12 -0700
commit85832d02c0a44250d4630c7951e97fcd4e7dd8c1 (patch)
tree1686f59ef454a2b088a4e5e556991ded73c1bbcc /weed/shell/command_volume_tier_move.go
parent1098ed0d78ce63d0e5435950e8495a339783376c (diff)
downloadseaweedfs-85832d02c0a44250d4630c7951e97fcd4e7dd8c1.tar.xz
seaweedfs-85832d02c0a44250d4630c7951e97fcd4e7dd8c1.zip
wait for goroutines
Diffstat (limited to 'weed/shell/command_volume_tier_move.go')
-rw-r--r--weed/shell/command_volume_tier_move.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.go
index d370d93e4..9719b442d 100644
--- a/weed/shell/command_volume_tier_move.go
+++ b/weed/shell/command_volume_tier_move.go
@@ -109,6 +109,7 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
hasFoundTarget := false
keepDataNodesSorted(allLocations, toDiskType)
fn := capacityByFreeVolumeCount(toDiskType)
+ wg := sync.WaitGroup{}
for _, dst := range allLocations {
if fn(dst.dataNode) > 0 && !hasFoundTarget {
// ask the volume server to replicate the volume
@@ -145,6 +146,7 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
c.activeServers[dst.dataNode.Id] = struct{}{}
c.activeServersCond.L.Unlock()
+ wg.Add(1)
go func(dst location) {
if err := c.doMoveOneVolume(commandEnv, writer, vid, toDiskType, locations, sourceVolumeServer, dst); err != nil {
fmt.Fprintf(writer, "move volume %d %s => %s: %v\n", vid, sourceVolumeServer, dst.dataNode.Id, err)
@@ -152,11 +154,14 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
delete(c.activeServers, sourceVolumeServer)
delete(c.activeServers, dst.dataNode.Id)
c.activeServersCond.Signal()
+ wg.Done()
}(dst)
}
}
+ wg.Wait()
+
if !hasFoundTarget {
fmt.Fprintf(writer, "can not find disk type %s for volume %d\n", toDiskType.ReadableString(), vid)
}