Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ttl: fix potential go leak for ttl in test #46953

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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