From 6111dcde52d8cd4d6ca3c128fb500d290e2d2afd Mon Sep 17 00:00:00 2001 From: congqixia Date: Fri, 1 Apr 2022 19:35:29 +0800 Subject: [PATCH] Fix ticker leakage in datanode flowgraph (#16346) Using in case ticker need to be closed may cause leakage Use time.NewTicker with deferred Stop instead Signed-off-by: Congqi Xia --- internal/datanode/flow_graph_time_ticker.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/datanode/flow_graph_time_ticker.go b/internal/datanode/flow_graph_time_ticker.go index 3de47a45fe..495c6bf9af 100644 --- a/internal/datanode/flow_graph_time_ticker.go +++ b/internal/datanode/flow_graph_time_ticker.go @@ -73,10 +73,11 @@ func (mt *mergedTimeTickerSender) bufferTs(ts Timestamp, segmentIDs []int64) { func (mt *mergedTimeTickerSender) tick() { defer mt.wg.Done() // this duration might be configuable in the future - t := time.Tick(time.Millisecond * 100) // 100 millisecond, 1/2 of rootcoord timetick duration + t := time.NewTicker(time.Millisecond * 100) // 100 millisecond, 1/2 of rootcoord timetick duration + defer t.Stop() for { select { - case <-t: + case <-t.C: mt.cond.L.Lock() mt.cond.Signal() // allow worker to check every 0.1s mt.cond.L.Unlock()