Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[improvement](statistics)Remove retry load when load stats cache fail. #28904

Merged
merged 1 commit into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.doris.statistics;

import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.TableIf;
import org.apache.doris.common.ThreadPoolManager;
import org.apache.doris.qe.InternalQueryExecutionException;
Expand Down Expand Up @@ -64,7 +63,8 @@ private Optional<ColumnStatistic> loadFromStatsTable(StatisticsCacheKey key) {
try {
columnResults = StatisticsRepository.loadColStats(key.tableId, key.idxId, key.colName);
} catch (InternalQueryExecutionException e) {
retryLoad(key);
LOG.info("Failed to load stats for table {} column {}. Reason:{}",
key.tableId, key.colName, e.getMessage());
return Optional.empty();
}
ColumnStatistic columnStatistics;
Expand All @@ -80,42 +80,4 @@ private Optional<ColumnStatistic> loadFromStatsTable(StatisticsCacheKey key) {
return Optional.of(columnStatistics);
}
}

private void retryLoad(StatisticsCacheKey key) {
singleThreadPool.submit(new RetryTask(key, 1));
}

private static class RetryTask implements Runnable {
StatisticsCacheKey key;
int retryTimes;

public RetryTask(StatisticsCacheKey key, int retryTimes) {
this.key = key;
this.retryTimes = retryTimes;
}

@Override
public void run() {
List<ResultRow> columnResults = null;
try {
columnResults = StatisticsRepository.loadColStats(key.tableId, key.idxId, key.colName);
} catch (InternalQueryExecutionException e) {
if (this.retryTimes < StatisticConstants.LOAD_RETRY_TIMES) {
retryTimes++;
singleThreadPool.submit(this);
}
return;
}
ColumnStatistic columnStatistics;
try {
columnStatistics = StatisticsUtil.deserializeToColumnStatistics(columnResults);
} catch (Exception e) {
LOG.warn("Exception to deserialize column statistics", e);
return;
}
if (columnStatistics != null) {
Env.getCurrentEnv().getStatisticsCache().putCache(key, columnStatistics);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@
import org.apache.logging.log4j.Logger;

import java.time.Duration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;
Expand Down Expand Up @@ -201,7 +199,6 @@ private void doPreHeat() {
if (CollectionUtils.isEmpty(recentStatsUpdatedCols)) {
return;
}
Map<StatisticsCacheKey, ColumnStatistic> keyToColStats = new HashMap<>();
for (ResultRow r : recentStatsUpdatedCols) {
try {
StatsId statsId = new StatsId(r);
Expand All @@ -211,7 +208,6 @@ private void doPreHeat() {
final StatisticsCacheKey k =
new StatisticsCacheKey(tblId, idxId, colId);
final ColumnStatistic c = ColumnStatistic.fromResultRow(r);
keyToColStats.put(k, c);
putCache(k, c);
} catch (Throwable t) {
LOG.warn("Error when preheating stats cache", t);
Expand Down
Loading