mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
volume.tier.move: avoid double counting
related to https://github.com/chrislusf/seaweedfs/issues/2637
This commit is contained in:
parent
0901438bd2
commit
c8c7c10c3f
|
@ -116,8 +116,10 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer
|
||||||
|
|
||||||
unlock := c.Lock(job.src)
|
unlock := c.Lock(job.src)
|
||||||
|
|
||||||
if err := c.doMoveOneVolume(commandEnv, writer, job.vid, toDiskType, locations, job.src, dst, applyChanges); err != nil {
|
if applyChanges {
|
||||||
fmt.Fprintf(writer, "move volume %d %s => %s: %v\n", job.vid, job.src, dst.dataNode.Id, err)
|
if err := c.doMoveOneVolume(commandEnv, writer, job.vid, toDiskType, locations, job.src, dst); err != nil {
|
||||||
|
fmt.Fprintf(writer, "move volume %d %s => %s: %v\n", job.vid, job.src, dst.dataNode.Id, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unlock()
|
unlock()
|
||||||
}
|
}
|
||||||
|
@ -216,34 +218,27 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *commandVolumeTierMove) doMoveOneVolume(commandEnv *CommandEnv, writer io.Writer, vid needle.VolumeId, toDiskType types.DiskType, locations []wdclient.Location, sourceVolumeServer pb.ServerAddress, dst location, applyChanges bool) (err error) {
|
func (c *commandVolumeTierMove) doMoveOneVolume(commandEnv *CommandEnv, writer io.Writer, vid needle.VolumeId, toDiskType types.DiskType, locations []wdclient.Location, sourceVolumeServer pb.ServerAddress, dst location) (err error) {
|
||||||
|
|
||||||
// mark all replicas as read only
|
// mark all replicas as read only
|
||||||
if applyChanges {
|
if err = markVolumeReplicasWritable(commandEnv.option.GrpcDialOption, vid, locations, false); err != nil {
|
||||||
if err = markVolumeReplicasWritable(commandEnv.option.GrpcDialOption, vid, locations, false); err != nil {
|
return fmt.Errorf("mark volume %d as readonly on %s: %v", vid, locations[0].Url, err)
|
||||||
return fmt.Errorf("mark volume %d as readonly on %s: %v", vid, locations[0].Url, err)
|
|
||||||
}
|
|
||||||
if err = LiveMoveVolume(commandEnv.option.GrpcDialOption, writer, vid, sourceVolumeServer, pb.NewServerAddressFromDataNode(dst.dataNode), 5*time.Second, toDiskType.ReadableString(), true); err != nil {
|
|
||||||
|
|
||||||
// mark all replicas as writable
|
|
||||||
if err = markVolumeReplicasWritable(commandEnv.option.GrpcDialOption, vid, locations, true); err != nil {
|
|
||||||
glog.Errorf("mark volume %d as writable on %s: %v", vid, locations[0].Url, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fmt.Errorf("move volume %d %s => %s : %v", vid, locations[0].Url, dst.dataNode.Id, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if err = LiveMoveVolume(commandEnv.option.GrpcDialOption, writer, vid, sourceVolumeServer, pb.NewServerAddressFromDataNode(dst.dataNode), 5*time.Second, toDiskType.ReadableString(), true); err != nil {
|
||||||
|
|
||||||
// adjust volume count
|
// mark all replicas as writable
|
||||||
dst.dataNode.DiskInfos[string(toDiskType)].VolumeCount++
|
if err = markVolumeReplicasWritable(commandEnv.option.GrpcDialOption, vid, locations, true); err != nil {
|
||||||
|
glog.Errorf("mark volume %d as writable on %s: %v", vid, locations[0].Url, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Errorf("move volume %d %s => %s : %v", vid, locations[0].Url, dst.dataNode.Id, err)
|
||||||
|
}
|
||||||
|
|
||||||
// remove the remaining replicas
|
// remove the remaining replicas
|
||||||
for _, loc := range locations {
|
for _, loc := range locations {
|
||||||
if loc.Url != dst.dataNode.Id && loc.ServerAddress() != sourceVolumeServer {
|
if loc.Url != dst.dataNode.Id && loc.ServerAddress() != sourceVolumeServer {
|
||||||
if applyChanges {
|
if err = deleteVolume(commandEnv.option.GrpcDialOption, vid, loc.ServerAddress()); err != nil {
|
||||||
if err = deleteVolume(commandEnv.option.GrpcDialOption, vid, loc.ServerAddress()); err != nil {
|
fmt.Fprintf(writer, "failed to delete volume %d on %s: %v\n", vid, loc.Url, err)
|
||||||
fmt.Fprintf(writer, "failed to delete volume %d on %s: %v\n", vid, loc.Url, err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// reduce volume count? Not really necessary since they are "more" full and will not be a candidate to move to
|
// reduce volume count? Not really necessary since they are "more" full and will not be a candidate to move to
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue