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
topology: wake the vacuum dispatcher when a worker frees quota (#11436)
Chris Lu56d2f05ccd01
diff --git a/weed/command/master.go b/weed/command/master.goindex 61bbea7305..5b29b914fa 100644--- a/weed/command/master.go+++ b/weed/command/master.go@@ -57,6 +57,7 @@ type MasterOptions struct {fileSizeLimitMB *intvolumePreallocate *boolmaxParallelVacuumPerServer *int+ vacuumIntervalSeconds *int// pulseSeconds *intdefaultReplication *stringgarbageThreshold *float64@@ -93,6 +94,7 @@ func init() {m.fileSizeLimitMB = cmdMaster.Flag.Int("fileSizeLimitMB", 256, "limit the file size accepted by /submit, should match the volume servers' -fileSizeLimitMB (-volume.fileSizeLimitMB under weed server or weed mini, which set this for you)")m.volumePreallocate = cmdMaster.Flag.Bool("volumePreallocate", false, "Preallocate disk space for volumes.")m.maxParallelVacuumPerServer = cmdMaster.Flag.Int("maxParallelVacuumPerServer", 1, "maximum number of volumes to vacuum in parallel per volume server")+ m.vacuumIntervalSeconds = cmdMaster.Flag.Int("vacuumIntervalSeconds", 840, "seconds between automatic vacuum sweeps")// m.pulseSeconds = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")m.defaultReplication = cmdMaster.Flag.String("defaultReplication", "", "Default replication type if not specified.")m.garbageThreshold = cmdMaster.Flag.Float64("garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")@@ -473,6 +475,7 @@ func (m *MasterOptions) toMasterOption(whiteList []string) *weed_server.MasterOpFileSizeLimitMB: *m.fileSizeLimitMB,VolumePreallocate: *m.volumePreallocate,MaxParallelVacuumPerServer: *m.maxParallelVacuumPerServer,+ VacuumIntervalSeconds: *m.vacuumIntervalSeconds,// PulseSeconds: *m.pulseSeconds,DefaultReplicaPlacement: *m.defaultReplication,GarbageThreshold: *m.garbageThreshold,diff --git a/weed/command/master_follower.go b/weed/command/master_follower.goindex 249f51dcf4..1a8ffefba9 100644--- a/weed/command/master_follower.go+++ b/weed/command/master_follower.go@@ -47,6 +47,7 @@ func init() {mf.metricsIntervalSec = aws.Int(0)mf.raftResumeState = aws.Bool(false)mf.maxParallelVacuumPerServer = aws.Int(1)+ mf.vacuumIntervalSeconds = aws.Int(840)mf.telemetryUrl = aws.String("https://telemetry.seaweedfs.com/api/collect")mf.telemetryEnabled = aws.Bool(false)}diff --git a/weed/command/mini.go b/weed/command/mini.goindex 5d8a54915d..2cf14a491e 100644--- a/weed/command/mini.go+++ b/weed/command/mini.go@@ -427,6 +427,7 @@ func initMiniMasterFlags() {miniMasterOptions.volumeSizeLimitMB = cmdMini.Flag.Uint("master.volumeSizeLimitMB", defaultMiniVolumeSizeMB, "Master stops directing writes to oversized volumes (default: 128MB for mini)")miniMasterOptions.volumePreallocate = cmdMini.Flag.Bool("master.volumePreallocate", false, "Preallocate disk space for volumes.")miniMasterOptions.maxParallelVacuumPerServer = cmdMini.Flag.Int("master.maxParallelVacuumPerServer", 1, "maximum number of volumes to vacuum in parallel on one volume server")+ miniMasterOptions.vacuumIntervalSeconds = cmdMini.Flag.Int("master.vacuumIntervalSeconds", 840, "seconds between automatic vacuum sweeps")miniMasterOptions.defaultReplication = cmdMini.Flag.String("master.defaultReplication", "", "Default replication type if not specified.")miniMasterOptions.garbageThreshold = cmdMini.Flag.Float64("master.garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")miniMasterOptions.metricsAddress = cmdMini.Flag.String("master.metrics.address", "", "Prometheus gateway address")diff --git a/weed/command/server.go b/weed/command/server.goindex 7ff8b9449c..b987fe9a3a 100644--- a/weed/command/server.go+++ b/weed/command/server.go@@ -98,6 +98,7 @@ func init() {masterOptions.volumeSizeLimitMB = cmdServer.Flag.Uint("master.volumeSizeLimitMB", util.DefaultVolumeSizeLimitMB, "Master stops directing writes to oversized volumes.")masterOptions.volumePreallocate = cmdServer.Flag.Bool("master.volumePreallocate", false, "Preallocate disk space for volumes.")masterOptions.maxParallelVacuumPerServer = cmdServer.Flag.Int("master.maxParallelVacuumPerServer", 1, "maximum number of volumes to vacuum in parallel on one volume server")+ masterOptions.vacuumIntervalSeconds = cmdServer.Flag.Int("master.vacuumIntervalSeconds", 840, "seconds between automatic vacuum sweeps")masterOptions.defaultReplication = cmdServer.Flag.String("master.defaultReplication", "", "Default replication type if not specified.")masterOptions.garbageThreshold = cmdServer.Flag.Float64("master.garbageThreshold", 0.3, "threshold to vacuum and reclaim spaces")masterOptions.metricsAddress = cmdServer.Flag.String("master.metrics.address", "", "Prometheus gateway address")diff --git a/weed/server/master_server.go b/weed/server/master_server.goindex 3a1364c113..73106c99b8 100644--- a/weed/server/master_server.go+++ b/weed/server/master_server.go@@ -51,6 +51,7 @@ type MasterOption struct {FileSizeLimitMB intVolumePreallocate boolMaxParallelVacuumPerServer int+ VacuumIntervalSeconds int// PulseSeconds intDefaultReplicaPlacement stringGarbageThreshold float64@@ -202,6 +203,7 @@ func NewMasterServer(r *mux.Router, option *MasterOption, peers map[string]pb.Sems.option.MaxParallelVacuumPerServer,topology.VolumeGrowStrategy.Threshold,ms.preallocateSize,+ time.Duration(ms.option.VacuumIntervalSeconds)*time.Second,)ms.ProcessGrowRequest()diff --git a/weed/topology/topology_event_handling.go b/weed/topology/topology_event_handling.goindex 665dfe16cf..c5c031a676 100644--- a/weed/topology/topology_event_handling.go+++ b/weed/topology/topology_event_handling.go@@ -13,7 +13,10 @@ import ("github.com/seaweedfs/seaweedfs/weed/storage")-func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, garbageThreshold float64, concurrentVacuumLimitPerVolumeServer int, growThreshold float64, preallocate int64) {+func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, garbageThreshold float64, concurrentVacuumLimitPerVolumeServer int, growThreshold float64, preallocate int64, vacuumInterval time.Duration) {+ if vacuumInterval <= 0 {+ vacuumInterval = 14 * time.Minute+ }go func() {for {if t.IsLeader() {@@ -41,7 +44,7 @@ func (t *Topology) StartRefreshWritableVolumes(grpcDialOption grpc.DialOption, g} else {stats.MasterReplicaPlacementMismatch.Reset()}- time.Sleep(14*time.Minute + time.Duration(120*rand.Float32())*time.Second)+ time.Sleep(vacuumInterval + time.Duration(120*rand.Float32())*time.Second)}}(garbageThreshold)go func() {diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.goindex 0205459d56..171f848ce1 100644--- a/weed/topology/topology_vacuum.go+++ b/weed/topology/topology_vacuum.go@@ -285,6 +285,7 @@ func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLexecutor := util.NewLimitedConcurrentExecutor(100)var wg sync.WaitGroup+ quotaFreed := make(chan struct{}, 1)for len(todoVolumeMap) > 0 {pendingVolumeMap := make(map[needle.VolumeId]*VolumeLocationList)@@ -321,6 +322,10 @@ func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLlimiter[dn.Id()]++limiterLock.Unlock()}+ select {+ case quotaFreed <- struct{}{}:+ default:+ }})if automatic && t.IsVacuumDisabled() {break@@ -330,7 +335,10 @@ func (t *Topology) vacuumOneVolumeLayout(grpcDialOption grpc.DialOption, volumeLbreak}if len(todoVolumeMap) == len(pendingVolumeMap) {- time.Sleep(10 * time.Second)+ select {+ case <-quotaFreed:+ case <-time.After(10 * time.Second):+ }}todoVolumeMap = pendingVolumeMap}