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.

prevent compacting on the same volume

chrislue8462ba3ad00
diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go
index 6bbbde71da..9f277d4f5b 100644
--- a/weed/storage/volume_vacuum.go
+++ b/weed/storage/volume_vacuum.go
@@ -46,6 +46,10 @@ func (v *Volume) Compact(preallocate int64, compactionBytePerSecond int64) error
//v.accessLock.Lock()
//defer v.accessLock.Unlock()
//glog.V(3).Infof("Got Compaction lock...")
+ if v.isCompacting || v.isCommitCompacting {
+ glog.V(0).Infof("Volume %d is already compacting...", v.Id)
+ return nil
+ }
v.isCompacting = true
defer func() {
v.isCompacting = false
@@ -71,6 +75,10 @@ func (v *Volume) Compact2(preallocate int64, compactionBytePerSecond int64, prog
}
glog.V(3).Infof("Compact2 volume %d ...", v.Id)
+ if v.isCompacting || v.isCommitCompacting {
+ glog.V(0).Infof("Volume %d is already compacting2 ...", v.Id)
+ return nil
+ }
v.isCompacting = true
defer func() {
v.isCompacting = false
@@ -105,6 +113,10 @@ func (v *Volume) CommitCompact() error {
}
glog.V(0).Infof("Committing volume %d vacuuming...", v.Id)
+ if v.isCommitCompacting {
+ glog.V(0).Infof("Volume %d is already commit compacting ...", v.Id)
+ return nil
+ }
v.isCommitCompacting = true
defer func() {
v.isCommitCompacting = false