Skip to content

Commit

Permalink
fix bug: context timeout inside for loop, it will case memory leak (#999
Browse files Browse the repository at this point in the history
)
  • Loading branch information
maaars authored Feb 22, 2025
1 parent 14a14f7 commit c729fe3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions replication/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c729fe3

Please sign in to comment.