This is an automated email from the ASF dual-hosted git repository.
dataroaring 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 551a2c0b742 [enhance](InternalTable) Set timeout for cache hotspot
table's insert stmt (#36279)
551a2c0b742 is described below
commit 551a2c0b7429f28e0638c8a64dadfbbe48cb8e14
Author: AlexYue <[email protected]>
AuthorDate: Sat Jun 15 23:29:41 2024 +0800
[enhance](InternalTable) Set timeout for cache hotspot table's insert stmt
(#36279)
Previously the insert stmt of cache hot spot table doesn't set the
insert timeout, sometimes it would last a long time. This pr adds one
session variable to control it.
---
.../apache/doris/cloud/CacheHotspotManagerUtils.java | 19 ++++++++++++++++++-
.../java/org/apache/doris/qe/SessionVariable.java | 6 ++++++
2 files changed, 24 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/cloud/CacheHotspotManagerUtils.java
b/fe/fe-core/src/main/java/org/apache/doris/cloud/CacheHotspotManagerUtils.java
index 5f3d9aad7c1..8e46547ae6c 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/cloud/CacheHotspotManagerUtils.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/cloud/CacheHotspotManagerUtils.java
@@ -19,7 +19,9 @@ package org.apache.doris.cloud;
import org.apache.doris.analysis.CreateDbStmt;
import org.apache.doris.analysis.DbName;
+import org.apache.doris.analysis.SetType;
import org.apache.doris.analysis.UserIdentity;
+import org.apache.doris.analysis.VariableExpr;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.Table;
@@ -28,6 +30,7 @@ import org.apache.doris.common.FeConstants;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.qe.SessionVariable;
import org.apache.doris.qe.StmtExecutor;
+import org.apache.doris.qe.VariableMgr;
import org.apache.doris.statistics.ResultRow;
import org.apache.doris.statistics.util.StatisticsUtil;
import org.apache.doris.thrift.TUniqueId;
@@ -43,6 +46,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
public class CacheHotspotManagerUtils {
+ public static final int CACHE_HOT_SPOT_INSERT_TIMEOUT_IN_SEC = 300;
private static final Logger LOG =
LogManager.getLogger(CacheHotspotManagerUtils.class);
private static final String TABLE_NAME = String.format("%s.%s",
FeConstants.INTERNAL_DB_NAME,
FeConstants.INTERNAL_FILE_CACHE_HOTSPOT_TABLE_NAME);
@@ -96,9 +100,21 @@ public class CacheHotspotManagerUtils {
+ "partition_name, index_id, insert_day order by insert_day
desc,\n"
+ "query_per_day_total desc, query_per_week_total desc)\n"
+ "select distinct table_id, table_name, partition_id, index_id
from t;";
-
private static String INTERNAL_TABLE_ID;
+ private static int getCacheHotSpotInsertTimeoutInSecTimeout() {
+ try {
+ SessionVariable sessionVariable =
VariableMgr.getDefaultSessionVariable();
+ VariableExpr variableExpr = new
VariableExpr(SessionVariable.INTERNAL_CACHE_HOT_SPOT_TIMEOUT,
+ SetType.GLOBAL);
+ VariableMgr.getValue(sessionVariable, variableExpr);
+ return sessionVariable.cacheHotSpotTimeoutS;
+ } catch (Exception e) {
+ LOG.warn("Failed to get value of table_stats_health_threshold,
return default", e);
+ }
+ return CACHE_HOT_SPOT_INSERT_TIMEOUT_IN_SEC;
+ }
+
public static boolean clusterContains(String clusterId) {
if (clusterId == null) {
return false;
@@ -225,6 +241,7 @@ public class CacheHotspotManagerUtils {
connectContext.setStartTime();
connectContext.setCurrentUserIdentity(UserIdentity.ROOT);
connectContext.setQualifiedUser(UserIdentity.ROOT.getQualifiedUser());
+
connectContext.setUserInsertTimeout(getCacheHotSpotInsertTimeoutInSecTimeout());
return new AutoCloseConnectContext(connectContext);
}
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
index 23ab0fb2701..f25ac66befc 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/SessionVariable.java
@@ -84,6 +84,8 @@ public class SessionVariable implements Serializable,
Writable {
public static final String QUERY_TIMEOUT = "query_timeout";
public static final String ANALYZE_TIMEOUT = "analyze_timeout";
+ public static final String INTERNAL_CACHE_HOT_SPOT_TIMEOUT =
"cache_hot_spot_insert_timeout_second";
+
public static final String MAX_EXECUTION_TIME = "max_execution_time";
public static final String INSERT_TIMEOUT = "insert_timeout";
public static final String ENABLE_PROFILE = "enable_profile";
@@ -669,6 +671,10 @@ public class SessionVariable implements Serializable,
Writable {
@VariableMgr.VarAttr(name = ANALYZE_TIMEOUT, flag = VariableMgr.GLOBAL,
needForward = true)
public int analyzeTimeoutS = 43200;
+ // insert timeout in second
+ @VariableMgr.VarAttr(name = INTERNAL_CACHE_HOT_SPOT_TIMEOUT, flag =
VariableMgr.GLOBAL, needForward = true)
+ public int cacheHotSpotTimeoutS = 300;
+
// The global max_execution_time value provides the default for the
session value for new connections.
// The session value applies to SELECT executions executed within the
session that include
// no MAX_EXECUTION_TIME(N) optimizer hint or for which N is 0.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]