Skip to content

Commit b36dc72

Browse files
authored
domain: set right order to compaign stats owner (#57200) (#57236)
close #57199
1 parent ef73392 commit b36dc72

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/domain/domain.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,11 @@ func (do *Domain) LoadBindInfoLoop(ctxForHandle sessionctx.Context, ctxForEvolve
20062006
}
20072007

20082008
owner := do.newOwnerManager(bindinfo.Prompt, bindinfo.OwnerKey)
2009+
err = owner.CampaignOwner()
2010+
if err != nil {
2011+
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
2012+
return err
2013+
}
20092014
do.globalBindHandleWorkerLoop(owner)
20102015
return nil
20112016
}
@@ -2330,6 +2335,13 @@ func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx sessionctx.Context) err
23302335
variable.DisableStatsOwner = do.disableStatsOwner
23312336
do.statsOwner = do.newOwnerManager(handle.StatsPrompt, handle.StatsOwnerKey)
23322337
do.statsOwner.SetListener(owner.NewListenersWrapper(statsHandle, do.ddlNotifier))
2338+
if config.GetGlobalConfig().Instance.TiDBEnableStatsOwner.Load() {
2339+
err := do.statsOwner.CampaignOwner()
2340+
if err != nil {
2341+
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
2342+
return err
2343+
}
2344+
}
23332345
do.wg.Run(func() {
23342346
do.indexUsageWorker()
23352347
}, "indexUsageWorker")
@@ -2438,13 +2450,6 @@ func (do *Domain) newOwnerManager(prompt, ownerKey string) owner.Manager {
24382450
} else {
24392451
statsOwner = owner.NewOwnerManager(context.Background(), do.etcdClient, prompt, id, ownerKey)
24402452
}
2441-
// TODO: Need to do something when err is not nil.
2442-
if ownerKey == handle.StatsOwnerKey && config.GetGlobalConfig().Instance.TiDBEnableStatsOwner.Load() {
2443-
err := statsOwner.CampaignOwner()
2444-
if err != nil {
2445-
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
2446-
}
2447-
}
24482453
return statsOwner
24492454
}
24502455

0 commit comments

Comments
 (0)