Skip to content

Commit

Permalink
ttl: fix potential go leak for ttl in test (#46953)
Browse files Browse the repository at this point in the history
close #46948
  • Loading branch information
lcwangchao authored Sep 14, 2023
1 parent 1159bc8 commit 1675fde
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ func (do *Domain) Close() {
}
ttlJobManager := do.ttlJobManager.Load()
if ttlJobManager != nil {
logutil.BgLogger().Info("stopping ttlJobManager")
ttlJobManager.Stop()
err := ttlJobManager.WaitStopped(context.Background(), func() time.Duration {
if intest.InTest {
Expand All @@ -1004,6 +1005,8 @@ func (do *Domain) Close() {
}())
if err != nil {
logutil.BgLogger().Warn("fail to wait until the ttl job manager stop", zap.Error(err))
} else {
logutil.BgLogger().Info("ttlJobManager exited.")
}
}
do.releaseServerID(context.Background())
Expand Down Expand Up @@ -2915,17 +2918,9 @@ func (do *Domain) serverIDKeeper() {

// StartTTLJobManager creates and starts the ttl job manager
func (do *Domain) StartTTLJobManager() {
do.wg.Run(func() {
defer func() {
logutil.BgLogger().Info("ttlJobManager exited.")
}()

ttlJobManager := ttlworker.NewJobManager(do.ddl.GetID(), do.sysSessionPool, do.store, do.etcdClient, do.ddl.OwnerManager().IsOwner)
do.ttlJobManager.Store(ttlJobManager)
ttlJobManager.Start()

<-do.exit
}, "ttlJobManager")
ttlJobManager := ttlworker.NewJobManager(do.ddl.GetID(), do.sysSessionPool, do.store, do.etcdClient, do.ddl.OwnerManager().IsOwner)
do.ttlJobManager.Store(ttlJobManager)
ttlJobManager.Start()
}

// TTLJobManager returns the ttl job manager on this domain
Expand Down

0 comments on commit 1675fde

Please sign in to comment.