This is an automated email from the ASF dual-hosted git repository.
lide 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 6b7c12fb805 [enhancement] Support TCP Keep-Alive on MySQL connections
(#43904)
6b7c12fb805 is described below
commit 6b7c12fb805fb6f36297a3b6488a87d9f7f042f9
Author: lide <[email protected]>
AuthorDate: Thu Dec 5 16:48:29 2024 +0800
[enhancement] Support TCP Keep-Alive on MySQL connections (#43904)
The default behavior of Options.KEEP_ALIVE is typically disabled,
meaning that TCP keep-alive is not enabled by default. This means that
if you do not explicitly enable it, the connection will not send
keep-alive probes when idle.
Co-authored-by: derenli <[email protected]>
---
.../src/main/java/org/apache/doris/common/Config.java | 4 ++++
.../src/main/java/org/apache/doris/mysql/MysqlServer.java | 11 +++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index 2ef391bb7ab..247c61ecd36 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -425,6 +425,10 @@ public class Config extends ConfigBase {
+ "`/proc/sys/net/core/somaxconn` at the same time"})
public static int mysql_nio_backlog_num = 1024;
+ @ConfField(description = {"是否启用 mysql 连接中的 TCP keep alive,默认禁用",
+ "Whether to enable TCP Keep-Alive for MySQL connections, disabled
by default"})
+ public static boolean mysql_nio_enable_keep_alive = false;
+
@ConfField(description = {"thrift client 的连接超时时间,单位是毫秒。0 表示不设置超时时间。",
"The connection timeout of thrift client, in milliseconds. 0 means
no timeout."})
public static int thrift_client_timeout_ms = 0;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlServer.java
b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlServer.java
index 5f70e3000b9..e7a888cdd24 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlServer.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlServer.java
@@ -68,14 +68,17 @@ public class MysqlServer {
// return true if success, otherwise false
public boolean start() {
try {
+ OptionMap optionMap = OptionMap.builder()
+ .set(Options.TCP_NODELAY, true)
+ .set(Options.BACKLOG, Config.mysql_nio_backlog_num)
+ .set(Options.KEEP_ALIVE,
Config.mysql_nio_enable_keep_alive)
+ .getMap();
if (FrontendOptions.isBindIPV6()) {
server = xnioWorker.createStreamConnectionServer(new
InetSocketAddress("::0", port), acceptListener,
- OptionMap.create(Options.TCP_NODELAY, true,
Options.BACKLOG, Config.mysql_nio_backlog_num));
-
+ optionMap);
} else {
server = xnioWorker.createStreamConnectionServer(new
InetSocketAddress(port), acceptListener,
- OptionMap.create(Options.TCP_NODELAY, true,
Options.BACKLOG, Config.mysql_nio_backlog_num));
-
+ optionMap);
}
server.resumeAccepts();
running = true;
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]