Skip to content

Commit

Permalink
domain: set right order to compaign stats owner (#57200) (#57236)
Browse files Browse the repository at this point in the history
close #57199
  • Loading branch information
ti-chi-bot authored Nov 11, 2024
1 parent ef73392 commit b36dc72
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/domain/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -2006,6 +2006,11 @@ func (do *Domain) LoadBindInfoLoop(ctxForHandle sessionctx.Context, ctxForEvolve
}

owner := do.newOwnerManager(bindinfo.Prompt, bindinfo.OwnerKey)
err = owner.CampaignOwner()
if err != nil {
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
return err
}
do.globalBindHandleWorkerLoop(owner)
return nil
}
Expand Down Expand Up @@ -2330,6 +2335,13 @@ func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx sessionctx.Context) err
variable.DisableStatsOwner = do.disableStatsOwner
do.statsOwner = do.newOwnerManager(handle.StatsPrompt, handle.StatsOwnerKey)
do.statsOwner.SetListener(owner.NewListenersWrapper(statsHandle, do.ddlNotifier))
if config.GetGlobalConfig().Instance.TiDBEnableStatsOwner.Load() {
err := do.statsOwner.CampaignOwner()
if err != nil {
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
return err
}
}
do.wg.Run(func() {
do.indexUsageWorker()
}, "indexUsageWorker")
Expand Down Expand Up @@ -2438,13 +2450,6 @@ func (do *Domain) newOwnerManager(prompt, ownerKey string) owner.Manager {
} else {
statsOwner = owner.NewOwnerManager(context.Background(), do.etcdClient, prompt, id, ownerKey)
}
// TODO: Need to do something when err is not nil.
if ownerKey == handle.StatsOwnerKey && config.GetGlobalConfig().Instance.TiDBEnableStatsOwner.Load() {
err := statsOwner.CampaignOwner()
if err != nil {
logutil.BgLogger().Warn("campaign owner failed", zap.Error(err))
}
}
return statsOwner
}

Expand Down

0 comments on commit b36dc72

Please sign in to comment.