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.

master: avoid timer leakage

Chris Lu410b818aa7d9
diff --git a/weed/topology/topology_vacuum.go b/weed/topology/topology_vacuum.go
index 4f3d69627a..7bf55d131b 100644
--- a/weed/topology/topology_vacuum.go
+++ b/weed/topology/topology_vacuum.go
@@ -42,13 +42,17 @@ func batchVacuumVolumeCheck(grpcDialOption grpc.DialOption, vl *VolumeLayout, vi
}(index, dn.Url(), vid)
}
vacuumLocationList := NewVolumeLocationList()
+
+ waitTimeout := time.NewTimer(30 * time.Minute)
+ defer waitTimeout.Stop()
+
for range locationlist.list {
select {
case index := <-ch:
if index != -1 {
vacuumLocationList.list = append(vacuumLocationList.list, locationlist.list[index])
}
- case <-time.After(30 * time.Minute):
+ case <-waitTimeout.C:
return vacuumLocationList, false
}
}
@@ -81,11 +85,15 @@ func batchVacuumVolumeCompact(grpcDialOption grpc.DialOption, vl *VolumeLayout,
}(index, dn.Url(), vid)
}
isVacuumSuccess := true
+
+ waitTimeout := time.NewTimer(30 * time.Minute)
+ defer waitTimeout.Stop()
+
for range locationlist.list {
select {
case canCommit := <-ch:
isVacuumSuccess = isVacuumSuccess && canCommit
- case <-time.After(30 * time.Minute):
+ case <-waitTimeout.C:
return false
}
}