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.

fix from comment delete volume is empty (#4573)

Konstantin Lebedev4527ead2956c
diff --git a/go.mod b/go.mod
index 6339ebb8f3..d0af8fab63 100644
--- a/go.mod
+++ b/go.mod
@@ -31,7 +31,7 @@ require (
github.com/fclairamb/ftpserverlib v0.21.0
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-errors/errors v1.1.1 // indirect
- github.com/go-redis/redis/v8 v8.11.5
+ github.com/go-redis/redis/v8 v8.11.5 // indirect
github.com/go-redsync/redsync/v4 v4.8.1
github.com/go-sql-driver/mysql v1.7.1
github.com/go-zookeeper/zk v1.0.3 // indirect
@@ -150,6 +150,7 @@ require (
github.com/hashicorp/raft-boltdb/v2 v2.2.2
github.com/rabbitmq/amqp091-go v1.8.1
github.com/rclone/rclone v1.62.2
+ github.com/redis/go-redis/v9 v9.0.2
github.com/schollz/progressbar/v3 v3.13.1
github.com/tikv/client-go/v2 v2.0.7
github.com/ydb-platform/ydb-go-sdk-auth-environ v0.2.0
diff --git a/go.sum b/go.sum
index c764ffba55..566eca93b7 100644
--- a/go.sum
+++ b/go.sum
@@ -653,7 +653,9 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dR
github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/bshuster-repo/logrus-logstash-hook v0.4.1/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk=
+github.com/bsm/ginkgo/v2 v2.5.0 h1:aOAnND1T40wEdAtkGSkvSICWeQ8L3UASX7YVCqQx+eQ=
github.com/bsm/ginkgo/v2 v2.5.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w=
+github.com/bsm/gomega v1.20.0 h1:JhAwLmtRzXFTx2AkALSLa8ijZafntmhSoU63Ok18Uq8=
github.com/bsm/gomega v1.20.0/go.mod h1:JifAceMQ4crZIWYUKrlGcmbN3bqHogVTADMD2ATsbwk=
github.com/buengese/sgzip v0.1.1 h1:ry+T8l1mlmiWEsDrH/YHZnCVWD2S3im1KLsyO+8ZmTU=
github.com/buengese/sgzip v0.1.1/go.mod h1:i5ZiXGF3fhV7gL1xaRRL1nDnmpNj0X061FQzOS8VMas=
diff --git a/weed/storage/store.go b/weed/storage/store.go
index cfc409c390..43d4595bf1 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -509,12 +509,12 @@ func (s *Store) UnmountVolume(i needle.VolumeId) error {
func (s *Store) DeleteVolume(i needle.VolumeId, onlyEmpty bool) error {
v := s.findVolume(i)
- if onlyEmpty && !v.IsEmpty() {
- return fmt.Errorf("delete volume %d not empty", i)
- }
if v == nil {
return fmt.Errorf("delete volume %d not found on disk", i)
}
+ if onlyEmpty && !v.IsEmpty() {
+ return fmt.Errorf("delete volume %d not empty", i)
+ }
message := master_pb.VolumeShortInformationMessage{
Id: uint32(v.Id),
Collection: v.Collection,
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index 31960451c3..066f06604a 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -333,5 +333,6 @@ func (v *Volume) IsReadOnly() bool {
return v.noWriteOrDelete || v.noWriteCanDelete || v.location.isDiskSpaceLow
}
func (v *Volume) IsEmpty() bool {
- return v.ContentSize() == 0
+ size, _, _ := v.DataBackend.GetStat()
+ return size <= 8 && v.ContentSize() == 0
}