[improvement](statistics)Catch load column stats exception, avoid print too much stack info to fe.out #30315

This commit is contained in:
Jibing-Li
2024-01-24 18:09:25 +08:00
committed by yiguolei
parent 83ea486b15
commit 63cf2777f9

View File

@ -42,18 +42,25 @@ public class ColumnStatisticsCacheLoader extends StatisticsCacheLoader<Optional<
@Override
protected Optional<ColumnStatistic> doLoad(StatisticsCacheKey key) {
// Load from statistics table.
Optional<ColumnStatistic> columnStatistic = loadFromStatsTable(key);
if (columnStatistic.isPresent()) {
return columnStatistic;
}
// Load from data source metadata
Optional<ColumnStatistic> columnStatistic = Optional.empty();
try {
TableIf table = StatisticsUtil.findTable(key.catalogId, key.dbId, key.tableId);
columnStatistic = table.getColumnStatistic(key.colName);
} catch (Exception e) {
LOG.debug(String.format("Exception to get column statistics by metadata. [Catalog:%d, DB:%d, Table:%d]",
key.catalogId, key.dbId, key.tableId), e);
// Load from statistics table.
columnStatistic = loadFromStatsTable(key);
if (columnStatistic.isPresent()) {
return columnStatistic;
}
// Load from data source metadata
try {
TableIf table = StatisticsUtil.findTable(key.catalogId, key.dbId, key.tableId);
columnStatistic = table.getColumnStatistic(key.colName);
} catch (Exception e) {
LOG.debug(String.format("Exception to get column statistics by metadata. [Catalog:{}, DB:{}, Table:{}]",
key.catalogId, key.dbId, key.tableId), e);
}
} catch (Throwable t) {
LOG.warn("Failed to load stats for column [Catalog:{}, DB:{}, Table:{}, Column:{}], Reason: {}",
key.catalogId, key.dbId, key.tableId, key.colName, t.getMessage());
LOG.debug(t);
}
return columnStatistic;
}