From 364bb6c7b477d3794cbbdf9ddc6a80d5347ab3cc Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 24 May 2024 17:15:12 -0700 Subject: [PATCH] avoid ticker leak --- .../bench_filer_upload/bench_filer_upload.go | 1 + .../stress_filer_upload_actual/stress_filer_upload.go | 1 + weed/server/master_grpc_server.go | 1 + weed/server/volume_grpc_client_to_master.go | 2 ++ 4 files changed, 5 insertions(+) diff --git a/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go b/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go index a41bf1da1..1767b04b2 100644 --- a/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go +++ b/unmaintained/stress_filer_upload/bench_filer_upload/bench_filer_upload.go @@ -66,6 +66,7 @@ func main() { go func() { ticker := time.NewTicker(1000 * time.Millisecond) + defer ticker.Stop() var lastTime time.Time var counter, size int64 diff --git a/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go b/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go index 83df54dc3..afcd51917 100644 --- a/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go +++ b/unmaintained/stress_filer_upload/stress_filer_upload_actual/stress_filer_upload.go @@ -72,6 +72,7 @@ func main() { go func() { ticker := time.NewTicker(500 * time.Millisecond) + defer ticker.Stop() var lastTime time.Time var counter, size int64 diff --git a/weed/server/master_grpc_server.go b/weed/server/master_grpc_server.go index 616b28e67..8feb909ad 100644 --- a/weed/server/master_grpc_server.go +++ b/weed/server/master_grpc_server.go @@ -297,6 +297,7 @@ func (ms *MasterServer) KeepConnected(stream master_pb.Seaweed_KeepConnectedServ }() ticker := time.NewTicker(5 * time.Second) + defer ticker.Stop() for { select { case message := <-messageChan: diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index e2cae079e..d2aa61a17 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -159,7 +159,9 @@ func (vs *VolumeServer) doHeartbeat(masterAddress pb.ServerAddress, grpcDialOpti } volumeTickChan := time.NewTicker(sleepInterval) + defer volumeTickChan.Stop() ecShardTickChan := time.NewTicker(17 * sleepInterval) + defer ecShardTickChan.Stop() dataCenter := vs.store.GetDataCenter() rack := vs.store.GetRack() ip := vs.store.Ip