File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -2228,9 +2228,26 @@ func (do *Domain) UpdateTableStatsLoop(ctx, initStatsCtx sessionctx.Context) err
2228
2228
return nil
2229
2229
}
2230
2230
do .SetStatsUpdating (true )
2231
+ // The stats updated worker doesn't require the stats initialization to be completed.
2232
+ // This is because the updated worker's primary responsibilities are to update the change delta and handle DDL operations.
2233
+ // These tasks do not interfere with or depend on the initialization process.
2231
2234
do .wg .Run (func () { do .updateStatsWorker (ctx , owner ) }, "updateStatsWorker" )
2232
- do .wg .Run (func () { do .autoAnalyzeWorker (owner ) }, "autoAnalyzeWorker" )
2233
- do .wg .Run (func () { do .analyzeJobsCleanupWorker (owner ) }, "analyzeJobsCleanupWorker" )
2235
+ // Wait for the stats worker to finish the initialization.
2236
+ // Otherwise, we may start the auto analyze worker before the stats cache is initialized.
2237
+ do .wg .Run (
2238
+ func () {
2239
+ <- do .StatsHandle ().InitStatsDone
2240
+ do .autoAnalyzeWorker (owner )
2241
+ },
2242
+ "autoAnalyzeWorker" ,
2243
+ )
2244
+ do .wg .Run (
2245
+ func () {
2246
+ <- do .StatsHandle ().InitStatsDone
2247
+ do .analyzeJobsCleanupWorker (owner )
2248
+ },
2249
+ "analyzeJobsCleanupWorker" ,
2250
+ )
2234
2251
return nil
2235
2252
}
2236
2253
You can’t perform that action at this time.
0 commit comments