Skip to content

Commit d0c3c33

Browse files
authored
domain: set right order to compaign stats owner (#57200)
close #57199
1 parent 225fb94 commit d0c3c33

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
@@ -2063,6 +2063,11 @@ func (do *Domain) LoadBindInfoLoop(ctxForHandle sessionctx.Context, ctxForEvolve
20632063
}
20642064

20652065
owner := do.newOwnerManager(bindinfo.Prompt, bindinfo.OwnerKey)
2066+
err = owner.CampaignOwner()
2067+
if err != nil {
2068+
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
2069+
return err
2070+
}
20662071
do.globalBindHandleWorkerLoop(owner)
20672072
return nil
20682073
}
@@ -2387,6 +2392,13 @@ func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx sessionctx.Context) err
23872392
variable.DisableStatsOwner = do.disableStatsOwner
23882393
do.statsOwner = do.newOwnerManager(handle.StatsPrompt, handle.StatsOwnerKey)
23892394
do.statsOwner.SetListener(owner.NewListenersWrapper(statsHandle, do.ddlNotifier))
2395+
if config.GetGlobalConfig().Instance.TiDBEnableStatsOwner.Load() {
2396+
err := do.statsOwner.CampaignOwner()
2397+
if err != nil {
2398+
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
2399+
return err
2400+
}
2401+
}
23902402
do.wg.Run(func() {
23912403
do.indexUsageWorker()
23922404
}, "indexUsageWorker")
@@ -2495,13 +2507,6 @@ func (do *Domain) newOwnerManager(prompt, ownerKey string) owner.Manager {
24952507
} else {
24962508
statsOwner = owner.NewOwnerManager(context.Background(), do.etcdClient, prompt, id, ownerKey)
24972509
}
2498-
// TODO: Need to do something when err is not nil.
2499-
if ownerKey == handle.StatsOwnerKey && config.GetGlobalConfig().Instance.TiDBEnableStatsOwner.Load() {
2500-
err := statsOwner.CampaignOwner()
2501-
if err != nil {
2502-
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
2503-
}
2504-
}
25052510
return statsOwner
25062511
}
25072512

0 commit comments

Comments
 (0)