[fix](statistics)Improve analyze timeout. (#33836) (#35530)

backport https://github.com/apache/doris/pull/33836

<!--Describe your changes.-->

## Further comments

If this is a relatively large or complex change, kick off the discussion
at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why
you chose the solution you did and what alternatives you considered,
etc...
This commit is contained in:
Jibing-Li
2024-05-28 17:12:53 +08:00
committed by GitHub
parent 63e63e114d
commit aa4fd3fd79
5 changed files with 15 additions and 5 deletions

View File

@ -811,7 +811,7 @@ public class AnalysisManager implements Writable {
executor.submit(() -> {
try {
if (cancelled) {
errorMessages.add("Query timeout or user cancelled."
errorMessages.add("Query Timeout or user Cancelled."
+ "Could set analyze_timeout to a bigger value.");
return;
}
@ -834,7 +834,7 @@ public class AnalysisManager implements Writable {
}
if (!colNames.isEmpty()) {
if (cancelled) {
throw new RuntimeException("Cancelled");
throw new RuntimeException("User Cancelled or Timeout.");
}
throw new RuntimeException("Failed to analyze following columns:[" + String.join(",", colNames)
+ "] Reasons: " + String.join(",", errorMessages));

View File

@ -56,6 +56,9 @@ public class ExternalAnalysisTask extends BaseAnalysisTask {
}
public void doExecute() throws Exception {
if (killed) {
return;
}
if (isTableLevelTask) {
getTableStats();
} else {

View File

@ -60,6 +60,9 @@ public class JdbcAnalysisTask extends BaseAnalysisTask {
}
public void doExecute() throws Exception {
if (killed) {
return;
}
if (isTableLevelTask) {
getTableStats();
} else {

View File

@ -65,6 +65,9 @@ public class OlapAnalysisTask extends BaseAnalysisTask {
}
public void doExecute() throws Exception {
if (killed) {
return;
}
List<Pair<String, String>> columnList = info.jobColumns;
if (StatisticsUtil.isEmptyTable(tbl, info.analysisMethod) || columnList == null || columnList.isEmpty()) {
StatsId statsId = new StatsId(concatColumnStatsId(), info.catalogId, info.dbId,

View File

@ -34,9 +34,10 @@ suite("test_hive_statistic_timeout", "p2,external,hive,external_remote,external_
sql """use ${catalog_name}.tpch_1000_parquet"""
sql """set global analyze_timeout=1"""
try {
sql """analyze table part (p_partkey, p_container, p_type, p_retailprice) with sync with full;"""
} catch (Exception e) {
assertTrue(e.getMessage().contains("Cancelled"));
test {
sql """analyze table part (p_partkey, p_container, p_type, p_retailprice) with sync with full;"""
exception "Timeout"
}
} finally {
sql """set global analyze_timeout=43200"""
}