Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

shell: volume.fsck deletes a volume is the volume has only orphaned data.

Chris Lu01adc567aae3
diff --git a/weed/shell/command_volume_fsck.go b/weed/shell/command_volume_fsck.go
index 0b40cfb7c9..2ced0f571c 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)
+ }
}
}
}