Skip to content

Commit

Permalink
executor: skip merging global stats if the partitioned table cannot b…
Browse files Browse the repository at this point in the history
…e found (#42462) (#42530)

close #42007
  • Loading branch information
ti-chi-bot authored Aug 16, 2023
1 parent 277834d commit c916686
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions executor/analyze_global_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func (e *AnalyzeExec) handleGlobalStats(ctx context.Context, needGlobalStats boo
continue
}
job := e.newAnalyzeHandleGlobalStatsJob(globalStatsID)
if job == nil {
logutil.BgLogger().Warn("cannot find the partitioned table, skip merging global stats", zap.Int64("tableID", globalStatsID.tableID))
continue
}
AddNewAnalyzeJob(e.ctx, job)
StartAnalyzeJob(e.ctx, job)
mergeStatsErr := func() error {
Expand Down Expand Up @@ -115,8 +119,14 @@ func (e *AnalyzeExec) handleGlobalStats(ctx context.Context, needGlobalStats boo
func (e *AnalyzeExec) newAnalyzeHandleGlobalStatsJob(key globalStatsKey) *statistics.AnalyzeJob {
dom := domain.GetDomain(e.ctx)
is := dom.InfoSchema()
table, _ := is.TableByID(key.tableID)
db, _ := is.SchemaByTable(table.Meta())
table, ok := is.TableByID(key.tableID)
if !ok {
return nil
}
db, ok := is.SchemaByTable(table.Meta())
if !ok {
return nil
}
dbName := db.Name.String()
tableName := table.Meta().Name.String()
jobInfo := fmt.Sprintf("merge global stats for %v.%v columns", dbName, tableName)
Expand Down

0 comments on commit c916686

Please sign in to comment.