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 <congqi.xia@zilliz.com>
This commit is contained in:
congqixia 2022-04-01 19:35:29 +08:00 committed by GitHub
parent e9090a62ab
commit 6111dcde52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()