This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push:
new 6f47055f5af [opt](profile) Disable show query/load profile stmt
(#32467) (#32813)
6f47055f5af is described below
commit 6f47055f5afe64c1033f6d96379cf793886af059
Author: zhiqiang <[email protected]>
AuthorDate: Tue Mar 26 13:56:46 2024 +0800
[opt](profile) Disable show query/load profile stmt (#32467) (#32813)
---
.../apache/doris/analysis/ShowLoadProfileStmt.java | 138 +++------------------
.../doris/analysis/ShowQueryProfileStmt.java | 136 ++------------------
.../java/org/apache/doris/qe/ShowExecutor.java | 125 ++-----------------
3 files changed, 38 insertions(+), 361 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowLoadProfileStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowLoadProfileStmt.java
index b3babe1e367..490a5211321 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowLoadProfileStmt.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowLoadProfileStmt.java
@@ -17,142 +17,32 @@
package org.apache.doris.analysis;
-import org.apache.doris.catalog.Column;
-import org.apache.doris.catalog.ScalarType;
-import org.apache.doris.common.AnalysisException;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.Config;
import org.apache.doris.common.UserException;
import org.apache.doris.qe.ShowResultSetMetaData;
-import com.google.common.base.Strings;
-
-// For stmt like:
-// show load profile "/"; # list all saving load job ids
-// show load profile "/e0f7390f5363419e-xxx" # show task ids of specified job
-// show load profile "/e0f7390f5363419e-xxx/e0f7390f5363419e-yyy/" # show
instance list of the task
-// show load profile
"/e0f7390f5363419e-xxx/e0f7390f5363419e-yyy/e0f7390f5363419e-zzz" # show
instance's graph
+// deprecated stmt, use will be guided to a specific url to get profile from
+// web browser
public class ShowLoadProfileStmt extends ShowStmt {
- private static final ShowResultSetMetaData META_DATA_TASK_IDS =
- ShowResultSetMetaData.builder()
- .addColumn(new Column("TaskId",
ScalarType.createVarchar(128)))
- .addColumn(new Column("ActiveTime",
ScalarType.createVarchar(64)))
- .build();
-
- public enum PathType {
- QUERY_IDS,
- TASK_IDS,
- FRAGMENTS,
- INSTANCES,
- SINGLE_INSTANCE
- }
-
- private String idPath;
- private PathType pathType;
-
- private String jobId = "";
- private String taskId = "";
- private String fragmentId = "";
- private String instanceId = "";
-
- public ShowLoadProfileStmt(String idPath) {
- this.idPath = idPath;
- }
-
- public PathType getPathType() {
- return pathType;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public String getTaskId() {
- return taskId;
- }
+ private String loadIdPath;
- public String getFragmentId() {
- return fragmentId;
- }
-
- public String getInstanceId() {
- return instanceId;
+ public ShowLoadProfileStmt(String path) {
+ this.loadIdPath = path;
}
@Override
public void analyze(Analyzer analyzer) throws UserException {
- super.analyze(analyzer);
- if (Strings.isNullOrEmpty(idPath)) {
- // list all query ids
- pathType = PathType.QUERY_IDS;
- return;
- }
-
- if (!idPath.startsWith("/")) {
- throw new AnalysisException("Path must starts with '/'");
- }
- pathType = PathType.QUERY_IDS;
- String[] parts = idPath.split("/");
- if (parts.length > 5) {
- throw new AnalysisException("Path must in format
'/jobId/taskId/fragmentId/instanceId'");
- }
-
- for (int i = 0; i < parts.length; i++) {
- switch (i) {
- case 0:
- pathType = PathType.QUERY_IDS;
- continue;
- case 1:
- jobId = parts[i];
- pathType = PathType.TASK_IDS;
- break;
- case 2:
- taskId = parts[i];
- pathType = PathType.FRAGMENTS;
- break;
- case 3:
- fragmentId = parts[i];
- pathType = PathType.INSTANCES;
- break;
- case 4:
- instanceId = parts[i];
- pathType = PathType.SINGLE_INSTANCE;
- break;
- default:
- break;
- }
- }
- }
-
- @Override
- public String toSql() {
- StringBuilder sb = new StringBuilder("SHOW LOAD PROFILE
").append(idPath);
- return sb.toString();
- }
-
- @Override
- public String toString() {
- return toSql();
+ String selfHost = Env.getCurrentEnv().getSelfNode().getHost();
+ int httpPort = Config.http_port;
+ String terminalMsg = String.format(
+ "try visit http://%s:%d/QueryProfile/%s, show query/load
profile syntax is a deprecated feature",
+ selfHost, httpPort, this.loadIdPath);
+ throw new UserException(terminalMsg);
}
@Override
public ShowResultSetMetaData getMetaData() {
- switch (pathType) {
- case QUERY_IDS:
- return ShowQueryProfileStmt.META_DATA_QUERY_IDS;
- case TASK_IDS:
- return META_DATA_TASK_IDS;
- case FRAGMENTS:
- return ShowQueryProfileStmt.META_DATA_FRAGMENTS;
- case INSTANCES:
- return ShowQueryProfileStmt.META_DATA_INSTANCES;
- case SINGLE_INSTANCE:
- return ShowQueryProfileStmt.META_DATA_SINGLE_INSTANCE;
- default:
- return null;
- }
- }
-
- @Override
- public RedirectStatus getRedirectStatus() {
- return RedirectStatus.FORWARD_NO_SYNC;
+ return null;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowQueryProfileStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowQueryProfileStmt.java
index f27840faa81..39d07743826 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowQueryProfileStmt.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ShowQueryProfileStmt.java
@@ -17,146 +17,32 @@
package org.apache.doris.analysis;
-import org.apache.doris.catalog.Column;
-import org.apache.doris.catalog.ScalarType;
-import org.apache.doris.common.AnalysisException;
+import org.apache.doris.catalog.Env;
+import org.apache.doris.common.Config;
import org.apache.doris.common.UserException;
-import org.apache.doris.common.profile.SummaryProfile;
import org.apache.doris.qe.ShowResultSetMetaData;
-import com.google.common.base.Strings;
-
-// For stmt like:
-// show query profile "/"; # list all saving query ids
-// show query profile "/e0f7390f5363419e-b416a2a79996083e" # show graph of
fragments of the query
-// show query profile "/e0f7390f5363419e-b416a2a79996083e/0" # show instance
list of the specified fragment
-// show query profile
"/e0f7390f5363419e-b416a2a79996083e/0/e0f7390f5363419e-b416a2a799960906" # show
instance's graph
+// deprecated stmt, use will be guided to a specific url to get profile from
+// web browser
public class ShowQueryProfileStmt extends ShowStmt {
- // This should be same as ProfileManager.PROFILE_HEADERS
- public static final ShowResultSetMetaData META_DATA_QUERY_IDS;
-
- public static final ShowResultSetMetaData META_DATA_FRAGMENTS =
- ShowResultSetMetaData.builder()
- .addColumn(new Column("Fragments",
ScalarType.createVarchar(65535)))
- .build();
- public static final ShowResultSetMetaData META_DATA_INSTANCES =
- ShowResultSetMetaData.builder()
- .addColumn(new Column("Instances",
ScalarType.createVarchar(128)))
- .addColumn(new Column("Host",
ScalarType.createVarchar(64)))
- .addColumn(new Column("ActiveTime",
ScalarType.createVarchar(64)))
- .build();
- public static final ShowResultSetMetaData META_DATA_SINGLE_INSTANCE =
- ShowResultSetMetaData.builder()
- .addColumn(new Column("Instance",
ScalarType.createVarchar(65535)))
- .build();
-
- static {
- ShowResultSetMetaData.Builder builder =
ShowResultSetMetaData.builder();
- for (String key : SummaryProfile.SUMMARY_KEYS) {
- builder.addColumn(new Column(key, ScalarType.createStringType()));
- }
- META_DATA_QUERY_IDS = builder.build();
- }
-
- public enum PathType {
- QUERY_IDS,
- FRAGMENTS,
- INSTANCES,
- SINGLE_INSTANCE
- }
-
private String queryIdPath;
- private PathType pathType;
-
- private String queryId = "";
- private String fragmentId = "";
- private String instanceId = "";
public ShowQueryProfileStmt(String queryIdPath) {
this.queryIdPath = queryIdPath;
}
- public PathType getPathType() {
- return pathType;
- }
-
- public String getQueryId() {
- return queryId;
- }
-
- public String getFragmentId() {
- return fragmentId;
- }
-
- public String getInstanceId() {
- return instanceId;
- }
-
@Override
public void analyze(Analyzer analyzer) throws UserException {
- super.analyze(analyzer);
- if (Strings.isNullOrEmpty(queryIdPath)) {
- // list all query ids
- pathType = PathType.QUERY_IDS;
- return;
- }
-
- if (!queryIdPath.startsWith("/")) {
- throw new AnalysisException("Query path must starts with '/'");
- }
- pathType = PathType.QUERY_IDS;
- String[] parts = queryIdPath.split("/");
- if (parts.length > 4) {
- throw new AnalysisException("Query path must in format
'/queryId/fragmentId/instanceId'");
- }
-
- for (int i = 0; i < parts.length; i++) {
- switch (i) {
- case 0:
- pathType = PathType.QUERY_IDS;
- continue;
- case 1:
- queryId = parts[i];
- pathType = PathType.FRAGMENTS;
- break;
- case 2:
- fragmentId = parts[i];
- pathType = PathType.INSTANCES;
- break;
- case 3:
- instanceId = parts[i];
- pathType = PathType.SINGLE_INSTANCE;
- break;
- default:
- break;
- }
- }
- }
-
- @Override
- public String toSql() {
- StringBuilder sb = new StringBuilder("SHOW QUERY PROFILE
").append(queryIdPath);
- return sb.toString();
- }
-
- @Override
- public String toString() {
- return toSql();
+ String selfHost = Env.getCurrentEnv().getSelfNode().getHost();
+ int httpPort = Config.http_port;
+ String terminalMsg = String.format(
+ "try visit http://%s:%d/QueryProfile/%s, show query/load
profile syntax is a deprecated feature",
+ selfHost, httpPort, this.queryIdPath);
+ throw new UserException(terminalMsg);
}
@Override
public ShowResultSetMetaData getMetaData() {
- switch (pathType) {
- case QUERY_IDS:
- return META_DATA_QUERY_IDS;
- case FRAGMENTS:
- return META_DATA_FRAGMENTS;
- case INSTANCES:
- return META_DATA_INSTANCES;
- case SINGLE_INSTANCE:
- return META_DATA_SINGLE_INSTANCE;
- default:
- return null;
- }
+ return null;
}
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
index ffd13e00eb3..3c1467453d7 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/ShowExecutor.java
@@ -167,8 +167,6 @@ import org.apache.doris.common.proc.SchemaChangeProcDir;
import org.apache.doris.common.proc.TabletsProcDir;
import org.apache.doris.common.proc.TrashProcDir;
import org.apache.doris.common.proc.TrashProcNode;
-import org.apache.doris.common.profile.ProfileTreeNode;
-import org.apache.doris.common.profile.ProfileTreePrinter;
import org.apache.doris.common.util.DebugUtil;
import org.apache.doris.common.util.ListComparator;
import org.apache.doris.common.util.LogBuilder;
@@ -176,8 +174,6 @@ import org.apache.doris.common.util.LogKey;
import org.apache.doris.common.util.NetUtils;
import org.apache.doris.common.util.OrderByPair;
import org.apache.doris.common.util.PrintableMap;
-import org.apache.doris.common.util.ProfileManager;
-import org.apache.doris.common.util.RuntimeProfile;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.CatalogIf;
@@ -219,6 +215,7 @@ import org.apache.doris.thrift.TShowProcessListResult;
import org.apache.doris.thrift.TTaskType;
import org.apache.doris.thrift.TUnit;
import org.apache.doris.transaction.GlobalTransactionMgr;
+import org.apache.doris.transaction.GlobalTransactionMgrIface;
import org.apache.doris.transaction.TransactionStatus;
import com.google.common.base.Preconditions;
@@ -227,7 +224,6 @@ import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.tuple.Triple;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -2337,116 +2333,21 @@ public class ShowExecutor {
}
private void handleShowQueryProfile() throws AnalysisException {
- ShowQueryProfileStmt showStmt = (ShowQueryProfileStmt) stmt;
- ShowQueryProfileStmt.PathType pathType = showStmt.getPathType();
- List<List<String>> rows = Lists.newArrayList();
- switch (pathType) {
- case QUERY_IDS:
- rows =
ProfileManager.getInstance().getQueryWithType(ProfileManager.ProfileType.QUERY);
- break;
- case FRAGMENTS: {
- ProfileTreeNode treeRoot =
ProfileManager.getInstance().getFragmentProfileTree(showStmt.getQueryId(),
- showStmt.getQueryId());
- if (treeRoot == null) {
- throw new AnalysisException("Failed to get fragment tree
for query: " + showStmt.getQueryId());
- }
- List<String> row =
Lists.newArrayList(ProfileTreePrinter.printFragmentTree(treeRoot));
- rows.add(row);
- break;
- }
- case INSTANCES: {
- // For query profile, there should be only one execution
profile,
- // And the execution id is same as query id
- List<Triple<String, String, Long>> instanceList
- = ProfileManager.getInstance().getFragmentInstanceList(
- showStmt.getQueryId(), showStmt.getQueryId(),
showStmt.getFragmentId());
- if (instanceList == null) {
- throw new AnalysisException("Failed to get instance list
for fragment: "
- + showStmt.getFragmentId());
- }
- for (Triple<String, String, Long> triple : instanceList) {
- List<String> row = Lists.newArrayList(triple.getLeft(),
triple.getMiddle(),
- RuntimeProfile.printCounter(triple.getRight(),
TUnit.TIME_NS));
- rows.add(row);
- }
- break;
- }
- case SINGLE_INSTANCE: {
- // For query profile, there should be only one execution
profile,
- // And the execution id is same as query id
- ProfileTreeNode treeRoot =
ProfileManager.getInstance().getInstanceProfileTree(showStmt.getQueryId(),
- showStmt.getQueryId(), showStmt.getFragmentId(),
showStmt.getInstanceId());
- if (treeRoot == null) {
- throw new AnalysisException("Failed to get instance tree
for instance: "
- + showStmt.getInstanceId());
- }
- List<String> row =
Lists.newArrayList(ProfileTreePrinter.printInstanceTree(treeRoot));
- rows.add(row);
- break;
- }
- default:
- break;
- }
-
- resultSet = new ShowResultSet(showStmt.getMetaData(), rows);
+ String selfHost = Env.getCurrentEnv().getSelfNode().getHost();
+ int httpPort = Config.http_port;
+ String terminalMsg = String.format(
+ "try visit http://%s:%d/QueryProfile, show query/load profile
syntax is a deprecated feature",
+ selfHost, httpPort);
+ throw new AnalysisException(terminalMsg);
}
private void handleShowLoadProfile() throws AnalysisException {
- ShowLoadProfileStmt showStmt = (ShowLoadProfileStmt) stmt;
- ShowLoadProfileStmt.PathType pathType = showStmt.getPathType();
- List<List<String>> rows = Lists.newArrayList();
- switch (pathType) {
- case QUERY_IDS:
- rows =
ProfileManager.getInstance().getQueryWithType(ProfileManager.ProfileType.LOAD);
- break;
- case TASK_IDS: {
- rows =
ProfileManager.getInstance().getLoadJobTaskList(showStmt.getJobId());
- break;
- }
- case FRAGMENTS: {
- ProfileTreeNode treeRoot =
ProfileManager.getInstance().getFragmentProfileTree(showStmt.getJobId(),
- showStmt.getTaskId());
- if (treeRoot == null) {
- throw new AnalysisException("Failed to get fragment tree
for load: " + showStmt.getJobId());
- }
- List<String> row =
Lists.newArrayList(ProfileTreePrinter.printFragmentTree(treeRoot));
- rows.add(row);
- break;
- }
- case INSTANCES: {
- // For load profile, there should be only one fragment in each
execution profile
- // And the fragment id is 0.
- List<Triple<String, String, Long>> instanceList
- =
ProfileManager.getInstance().getFragmentInstanceList(showStmt.getJobId(),
- showStmt.getTaskId(), ((ShowLoadProfileStmt)
stmt).getFragmentId());
- if (instanceList == null) {
- throw new AnalysisException("Failed to get instance list
for task: " + showStmt.getTaskId());
- }
- for (Triple<String, String, Long> triple : instanceList) {
- List<String> row = Lists.newArrayList(triple.getLeft(),
triple.getMiddle(),
- RuntimeProfile.printCounter(triple.getRight(),
TUnit.TIME_NS));
- rows.add(row);
- }
- break;
- }
- case SINGLE_INSTANCE: {
- // For load profile, there should be only one fragment in each
execution profile.
- // And the fragment id is 0.
- ProfileTreeNode treeRoot =
ProfileManager.getInstance().getInstanceProfileTree(showStmt.getJobId(),
- showStmt.getTaskId(), showStmt.getFragmentId(),
showStmt.getInstanceId());
- if (treeRoot == null) {
- throw new AnalysisException("Failed to get instance tree
for instance: "
- + showStmt.getInstanceId());
- }
- List<String> row =
Lists.newArrayList(ProfileTreePrinter.printInstanceTree(treeRoot));
- rows.add(row);
- break;
- }
- default:
- break;
- }
-
- resultSet = new ShowResultSet(showStmt.getMetaData(), rows);
+ String selfHost = Env.getCurrentEnv().getSelfNode().getHost();
+ int httpPort = Config.http_port;
+ String terminalMsg = String.format(
+ "try visit http://%s:%d/QueryProfile, show query/load profile
syntax is a deprecated feature",
+ selfHost, httpPort);
+ throw new AnalysisException(terminalMsg);
}
private void handleShowCreateRepository() throws AnalysisException {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]