You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2024/02/21 11:15:10 UTC
(doris) branch master updated: [fix](statistics)Release StmtExecutor in AnalysisTask object when sql execution finished to release memory. #31212
This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new dda483a9db2 [fix](statistics)Release StmtExecutor in AnalysisTask object when sql execution finished to release memory. #31212
dda483a9db2 is described below
commit dda483a9db2fa4f319b33ea009e8eb4a1ac1d615
Author: Jibing-Li <64...@users.noreply.github.com>
AuthorDate: Wed Feb 21 19:15:00 2024 +0800
[fix](statistics)Release StmtExecutor in AnalysisTask object when sql execution finished to release memory. #31212
---
.../java/org/apache/doris/statistics/BaseAnalysisTask.java | 2 ++
.../java/org/apache/doris/statistics/OlapAnalysisTask.java | 14 ++++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
index 789ae0b5637..68767843507 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/BaseAnalysisTask.java
@@ -317,6 +317,8 @@ public abstract class BaseAnalysisTask {
LOG.debug("End cost time in millisec: " + (System.currentTimeMillis() - startTime)
+ " Analyze SQL: " + sql + " QueryId: " + queryId);
}
+ // Release the reference to stmtExecutor, reduce memory usage.
+ stmtExecutor = null;
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java b/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java
index a7e2f1f4273..5a1d5829c8c 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/statistics/OlapAnalysisTask.java
@@ -26,6 +26,7 @@ import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Partition;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.Pair;
+import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.qe.AutoCloseConnectContext;
import org.apache.doris.qe.StmtExecutor;
import org.apache.doris.statistics.AnalysisInfo.JobType;
@@ -183,14 +184,23 @@ public class OlapAnalysisTask extends BaseAnalysisTask {
tbl.getName(), col.getName());
return null;
}
+ long startTime = System.currentTimeMillis();
Map<String, String> params = new HashMap<>();
params.put("dbName", db.getFullName());
params.put("colName", StatisticsUtil.escapeColumnName(info.colName));
params.put("tblName", tbl.getName());
params.put("index", getIndex());
StringSubstitutor stringSubstitutor = new StringSubstitutor(params);
- stmtExecutor = new StmtExecutor(context.connectContext, stringSubstitutor.replace(BASIC_STATS_TEMPLATE));
- return stmtExecutor.executeInternalQuery().get(0);
+ String sql = stringSubstitutor.replace(BASIC_STATS_TEMPLATE);
+ stmtExecutor = new StmtExecutor(context.connectContext, sql);
+ ResultRow resultRow = stmtExecutor.executeInternalQuery().get(0);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Cost time in millisec: " + (System.currentTimeMillis() - startTime)
+ + " Min max SQL: " + sql + " QueryId: " + DebugUtil.printId(stmtExecutor.getContext().queryId()));
+ }
+ // Release the reference to stmtExecutor, reduce memory usage.
+ stmtExecutor = null;
+ return resultRow;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org