From b65641c1390c12607dd37f9031e4b5bba80f0c6c Mon Sep 17 00:00:00 2001 From: maaars Date: Sat, 22 Feb 2025 17:56:42 +0800 Subject: [PATCH] fix bug: context timeout inside for loop, it will case memory leak --- replication/backup.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/replication/backup.go b/replication/backup.go index d3398b5f7..08f47473f 100644 --- a/replication/backup.go +++ b/replication/backup.go @@ -69,10 +69,10 @@ func (b *BinlogSyncer) StartBackupWithHandler(p mysql.Position, timeout time.Dur } }() - for { - ctx, cancel := context.WithTimeout(context.Background(), timeout) - defer cancel() + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + for { select { case <-ctx.Done(): return nil