aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_volume_fsck.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-07-12 11:22:00 -0700
committerChris Lu <chris.lu@gmail.com>2021-07-12 11:22:00 -0700
commit01adc567aae3b03e09601c4db1b413be1e0c90bc (patch)
treee4b0fc2859e701c01326bdc8fd50c339d6cd4e4c /weed/shell/command_volume_fsck.go
parent297b41266bb338ee9c9af2c8da36af4498739907 (diff)
downloadseaweedfs-01adc567aae3b03e09601c4db1b413be1e0c90bc.tar.xz
seaweedfs-01adc567aae3b03e09601c4db1b413be1e0c90bc.zip
shell: volume.fsck deletes a volume is the volume has only orphaned data.
fix https://github.com/chrislusf/seaweedfs/issues/2190
Diffstat (limited to 'weed/shell/command_volume_fsck.go')
-rw-r--r--weed/shell/command_volume_fsck.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go
index 0b40cfb7c..2ced0f571 100644
--- a/weed/shell/command_volume_fsck.go
+++ b/weed/shell/command_volume_fsck.go
@@ -5,6 +5,7 @@ import (
"context"
"flag"
"fmt"
+ "github.com/chrislusf/seaweedfs/weed/storage/needle"
"io"
"io/ioutil"
"math"
@@ -214,8 +215,14 @@ func (c *commandVolumeFsck) findExtraChunksInVolumeServers(volumeIdToVInfo map[u
if vinfo.isEcVolume {
fmt.Fprintf(writer, "Skip purging for Erasure Coded volumes.\n")
}
- if err := c.purgeFileIdsForOneVolume(volumeId, orphanFileIds, writer); err != nil {
- return fmt.Errorf("purge for volume %d: %v\n", volumeId, err)
+ if inUseCount == 0 {
+ if err := deleteVolume(c.env.option.GrpcDialOption, needle.VolumeId(volumeId), vinfo.server); err != nil {
+ return fmt.Errorf("delete volume %d: %v\n", volumeId, err)
+ }
+ } else {
+ if err := c.purgeFileIdsForOneVolume(volumeId, orphanFileIds, writer); err != nil {
+ return fmt.Errorf("purge for volume %d: %v\n", volumeId, err)
+ }
}
}
}