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.

use two flags: v.isCompacting and v.isCommitCompacting

chrislu37ab8909b00c
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go
index d618db2964..e928100223 100644
--- a/weed/storage/disk_location.go
+++ b/weed/storage/disk_location.go
@@ -283,7 +283,7 @@ func (l *DiskLocation) UnloadVolume(vid needle.VolumeId) error {
func (l *DiskLocation) unmountVolumeByCollection(collectionName string) map[needle.VolumeId]*Volume {
deltaVols := make(map[needle.VolumeId]*Volume, 0)
for k, v := range l.volumes {
- if v.Collection == collectionName && !v.isCompacting {
+ if v.Collection == collectionName && !v.isCompacting && !v.isCommitCompacting {
deltaVols[k] = v
}
}
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index f388c7d998..b4791692ee 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -42,7 +42,8 @@ type Volume struct {
lastCompactIndexOffset uint64
lastCompactRevision uint16
- isCompacting bool
+ isCompacting bool
+ isCommitCompacting bool
volumeInfo *volume_server_pb.VolumeInfo
location *DiskLocation
diff --git a/weed/storage/volume_vacuum.go b/weed/storage/volume_vacuum.go
index 7651420aa0..ac6f8f8d59 100644
--- a/weed/storage/volume_vacuum.go
+++ b/weed/storage/volume_vacuum.go
@@ -94,9 +94,9 @@ func (v *Volume) CommitCompact() error {
}
glog.V(0).Infof("Committing volume %d vacuuming...", v.Id)
- v.isCompacting = true
+ v.isCommitCompacting = true
defer func() {
- v.isCompacting = false
+ v.isCommitCompacting = false
}()
v.dataFileAccessLock.Lock()
diff --git a/weed/storage/volume_write.go b/weed/storage/volume_write.go
index 794b1c1256..7a96c96950 100644
--- a/weed/storage/volume_write.go
+++ b/weed/storage/volume_write.go
@@ -54,7 +54,7 @@ func (v *Volume) isFileUnchanged(n *needle.Needle) bool {
// Destroy removes everything related to this volume
func (v *Volume) Destroy() (err error) {
- if v.isCompacting {
+ if v.isCompacting || v.isCommitCompacting {
err = fmt.Errorf("volume %d is compacting", v.Id)
return
}