[enhancement](stats) Optimize stats pre-load logic #19138
1. Don't do pre-load until stats table gets ready 2. Don't put pre-loaded unknown stats to cache
This commit is contained in:
@ -20,6 +20,7 @@ package org.apache.doris.statistics;
|
||||
import org.apache.doris.common.ThreadPoolManager;
|
||||
import org.apache.doris.qe.ConnectContext;
|
||||
import org.apache.doris.statistics.util.InternalQueryResult.ResultRow;
|
||||
import org.apache.doris.statistics.util.StatisticsUtil;
|
||||
|
||||
import com.github.benmanes.caffeine.cache.AsyncLoadingCache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
@ -146,6 +147,14 @@ public class StatisticsCache {
|
||||
private void doPreHeat() {
|
||||
List<ResultRow> recentStatsUpdatedCols = null;
|
||||
long retryTimes = 0;
|
||||
while (!StatisticsUtil.statsTblAvailable()) {
|
||||
try {
|
||||
Thread.sleep(100L);
|
||||
} catch (InterruptedException e) {
|
||||
// IGNORE
|
||||
}
|
||||
}
|
||||
|
||||
while (retryTimes < StatisticConstants.PRELOAD_RETRY_TIMES) {
|
||||
try {
|
||||
recentStatsUpdatedCols = StatisticsRepository.fetchRecentStatsUpdatedCol();
|
||||
@ -194,6 +203,9 @@ public class StatisticsCache {
|
||||
return Optional.of(c);
|
||||
}
|
||||
};
|
||||
if (c == ColumnStatistic.UNKNOWN) {
|
||||
continue;
|
||||
}
|
||||
columnStatisticsCache.put(k, f);
|
||||
} catch (Throwable t) {
|
||||
LOG.warn("Error when preheating stats cache", t);
|
||||
|
||||
Reference in New Issue
Block a user