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.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
[shell] feat:stop vacuum immediately once volume.vacuum.disable was executed (#6375)
dsd72af97162fa4
diff --git a/weed/server/master_grpc_server_volume.go b/weed/server/master_grpc_server_volume.goindex 24e9c058c9..3a383e2598 100644--- a/weed/server/master_grpc_server_volume.go+++ b/weed/server/master_grpc_server_volume.go@@ -271,7 +271,7 @@ func (ms *MasterServer) VacuumVolume(ctx context.Context, req *master_pb.VacuumVresp := &master_pb.VacuumVolumeResponse{}- ms.Topo.Vacuum(ms.grpcDialOption, float64(req.GarbageThreshold), ms.option.MaxParallelVacuumPerServer, req.VolumeId, req.Collection, ms.preallocateSize)+ ms.Topo.Vacuum(ms.grpcDialOption, float64(req.GarbageThreshold), ms.option.MaxParallelVacuumPerServer, req.VolumeId, req.Collection, ms.preallocateSize, false)return resp, nil}diff --git a/weed/server/master_server_handlers_admin.go b/weed/server/master_server_handlers_admin.goindex 452a4194e7..fb0503e335 100644--- a/weed/server/master_server_handlers_admin.go+++ b/weed/server/master_server_handlers_admin.go@@ -3,12 +3,13 @@ package weed_serverimport ("context""fmt"- "github.com/seaweedfs/seaweedfs/weed/pb"- "github.com/seaweedfs/seaweedfs/weed/pb/master_pb""math/rand/v2""net/http""strconv"+ "github.com/seaweedfs/seaweedfs/weed/pb"+ "github.com/seaweedfs/seaweedfs/weed/pb/master_pb"+"github.com/seaweedfs/seaweedfs/weed/glog""github.com/seaweedfs/seaweedfs/weed/operation""github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"@@ -66,7 +67,7 @@ func (ms *MasterServer) volumeVacuumHandler(w http.ResponseWriter, r *http.Reque}}// glog.Infoln("garbageThreshold =", gcThreshold)- ms.Topo.Vacuum(ms.grpcDialOption, gcThreshold, ms.option.MaxParallelVacuumPerServer, 0, "", ms.preallocateSize)+ ms.Topo.Vacuum(ms.grpcDialOption, gcThreshold, ms.option.MaxParallelVacuumPerServer, 0, "", ms.preallocateSize, false)ms.dirStatusHandler(w, r)}diff --git a/weed/topology/topology_event_handling.go b/weed/topology/topology_event_handling.goindex 109f29ee08..e3ad8f2dce 100644--- a/weed/topology/topology_event_handling.go+++ b/weed/topology/topology_event_handling.go@@ -27,7 +27,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, gfor {if t.IsLeader() {if !t.isDisableVacuum {- t.Vacuum(grpcDialOption, garbageThreshold, concurrentVacuumLimitPerVolumeServer, 0, "", preallocate)+ t.Vacuum(grpcDialOption, garbageThreshold, concurrentVacuumLimitPerVolumeServer, 0, "", preallocate, true)}} else {stats.MasterReplicaPlacementMismatch.Reset()diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.goindex eb2ca8c3b7..83be65d7ca 100644--- a/weed/topology/topology_vacuum.go+++ b/weed/topology/topology_vacuum.go@@ -2,12 +2,13 @@ package topologyimport ("context"- "github.com/seaweedfs/seaweedfs/weed/util""io""sync""sync/atomic""time"+ "github.com/seaweedfs/seaweedfs/weed/util"+"github.com/seaweedfs/seaweedfs/weed/pb""google.golang.org/grpc"@@ -215,11 +216,12 @@ func (t *Topology) batchVacuumVolumeCleanup(grpcDialOption grpc.DialOption, vl *}}-func (t *Topology) Vacuum(grpcDialOption grpc.DialOption, garbageThreshold float64, maxParallelVacuumPerServer int, volumeId uint32, collection string, preallocate int64) {+func (t *Topology) Vacuum(grpcDialOption grpc.DialOption, garbageThreshold float64, maxParallelVacuumPerServer int, volumeId uint32, collection string, preallocate int64, automatic bool) {// if there is vacuum going on, return immediatelyswapped := atomic.CompareAndSwapInt64(&t.vacuumLockCounter, 0, 1)if !swapped {+ glog.V(0).Infof("Vacuum is already running")return}defer atomic.StoreInt64(&t.vacuumLockCounter, 0)@@ -245,14 +247,21 @@ func (t *Topology) Vacuum(grpcDialOption grpc.DialOption, garbageThreshold floatt.vacuumOneVolumeId(grpcDialOption, volumeLayout, c, garbageThreshold, locationList, vid, preallocate)}} else {- t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, maxParallelVacuumPerServer, preallocate)+ t.vacuumOneVolumeLayout(grpcDialOption, volumeLayout, c, garbageThreshold, maxParallelVacuumPerServer, preallocate, automatic)}}+ if automatic && t.isDisableVacuum {+ break+ }+ }+ if automatic && t.isDisableVacuum {+ glog.V(0).Infof("Vacuum is disabled")+ break}}}-func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLayout *VolumeLayout, c *Collection, garbageThreshold float64, maxParallelVacuumPerServer int, preallocate int64) {+func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLayout *VolumeLayout, c *Collection, garbageThreshold float64, maxParallelVacuumPerServer int, preallocate int64, automatic bool) {volumeLayout.accessLock.RLock()todoVolumeMap := make(map[needle.VolumeId]*VolumeLocationList)@@ -312,8 +321,13 @@ func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLlimiterLock.Unlock()}})+ if automatic && t.isDisableVacuum {+ break+ }+ }+ if automatic && t.isDisableVacuum {+ break}-if len(todoVolumeMap) == len(pendingVolumeMap) {time.Sleep(10 * time.Second)}