You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2021/08/30 10:30:44 UTC

[iotdb] branch master updated: [ISSUE-3865] Meaningless connection reset issues caused by low default value for SOMAXCONN (#3867)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 253bc96  [ISSUE-3865] Meaningless connection reset issues caused by low default value for SOMAXCONN (#3867)
253bc96 is described below

commit 253bc96e10c4765f2770ff3a376b40543939bf78
Author: Steve Yurong Su (宇荣) <ro...@apache.org>
AuthorDate: Mon Aug 30 05:30:02 2021 -0500

    [ISSUE-3865] Meaningless connection reset issues caused by low default value for SOMAXCONN (#3867)
---
 README.md                                       |  8 ++++++++
 README_ZH.md                                    |  8 ++++++++
 docs/Download/README.md                         | 10 +++++++++
 docs/zh/Download/README.md                      | 12 ++++++++++-
 server/src/assembly/resources/conf/iotdb-env.sh | 27 +++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 0522e5b..9a9b1e1 100644
--- a/README.md
+++ b/README.md
@@ -90,6 +90,14 @@ To use IoTDB, you need to have:
 1. Java >= 1.8 (1.8, 11, and 15 are verified. Please make sure the environment path has been set accordingly).
 2. Maven >= 3.6 (If you want to compile and install IoTDB from source code).
 3. Set the max open files num as 65535 to avoid "too many open files" error.
+4. (Optional) Set the somaxconn as 65535 to avoid "connection reset" error when the system is under high load.
+    ```
+    # Linux
+    > sudo sysctl -w net.core.somaxconn=65535
+   
+    # FreeBSD or Darwin
+    > sudo sysctl -w kern.ipc.somaxconn=65535
+    ```
 
 ## Installation
 
diff --git a/README_ZH.md b/README_ZH.md
index e40822a..8f5830e 100644
--- a/README_ZH.md
+++ b/README_ZH.md
@@ -87,6 +87,14 @@ IoTDB的主要特点如下:
 1. Java >= 1.8 (目前 1.8、11和15 已经被验证可用。请确保环变量境路径已正确设置)。
 2. Maven >= 3.6 (如果希望从源代码编译和安装IoTDB)。
 3. 设置 max open files 为 65535,以避免"too many open files"错误。
+4. (可选) 将 somaxconn 设置为 65535 以避免系统在高负载时出现 "connection reset" 错误。 
+    ```
+    # Linux
+    > sudo sysctl -w net.core.somaxconn=65535
+   
+    # FreeBSD or Darwin
+    > sudo sysctl -w kern.ipc.somaxconn=65535
+    ```
 
 ## 安装
 
diff --git a/docs/Download/README.md b/docs/Download/README.md
index 88f6ce2..9be974a 100644
--- a/docs/Download/README.md
+++ b/docs/Download/README.md
@@ -71,6 +71,16 @@ Legacy version are available here: [https://archive.apache.org/dist/iotdb/](http
 
 **<font color=red>Attention</font>**:
 
+- Recommended OS parameters
+  * Set the somaxconn as 65535 to avoid "connection reset" error when the system is under high load.
+    ```
+    # Linux
+    > sudo sysctl -w net.core.somaxconn=65535
+   
+    # FreeBSD or Darwin
+    > sudo sysctl -w kern.ipc.somaxconn=65535
+    ```
+
 - How to upgrade a minor version (e.g., from v0.11.0 to v0.11.3)?
   * versions which have the same major version are compatible.
   * Just download and unzip the new version. Then modify the configuration files to keep consistent 
diff --git a/docs/zh/Download/README.md b/docs/zh/Download/README.md
index 3e86873..ed75eef 100644
--- a/docs/zh/Download/README.md
+++ b/docs/zh/Download/README.md
@@ -67,7 +67,17 @@
 
 历史版本下载:[https://archive.apache.org/dist/iotdb/](https://archive.apache.org/dist/iotdb/)
 
-**<font color=red>升级注意事项</font>**:
+**<font color=red>注意事项</font>**:
+
+- 推荐修改的操作系统参数
+  * 将 somaxconn 设置为 65535 以避免系统在高负载时出现 "connection reset" 错误。
+    ```
+    # Linux
+    > sudo sysctl -w net.core.somaxconn=65535
+   
+    # FreeBSD or Darwin
+    > sudo sysctl -w kern.ipc.somaxconn=65535
+    ```
 
 - 如何升级小版本 (例如,从 v0.11.0 to v0.11.2)?
   * 同一个大版本下的多个小版本是互相兼容的。
diff --git a/server/src/assembly/resources/conf/iotdb-env.sh b/server/src/assembly/resources/conf/iotdb-env.sh
index 7c4774e..14118ec 100755
--- a/server/src/assembly/resources/conf/iotdb-env.sh
+++ b/server/src/assembly/resources/conf/iotdb-env.sh
@@ -30,6 +30,33 @@ if [ $max_num -le 65535 ]; then
     fi
 fi
 
+# Set somaxconn to a better value to avoid meaningless connection reset issues when the system is under high load.
+# The original somaxconn will be set back when the system reboots.
+# For more detail, see: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=19f92a030ca6d772ab44b22ee6a01378a8cb32d4
+SOMAXCONN=65535
+case "$(uname)" in
+    Linux)
+        somaxconn=$(sysctl net.core.somaxconn | awk '{print $2}')
+        if [ "$somaxconn" -lt $SOMAXCONN ]; then
+            echo "WARN:"
+            echo "WARN: the value of net.core.somaxconn (=$somaxconn) is too small, please set it to a larger value using the following command."
+            echo "WARN:     sudo sysctl -w net.core.somaxconn=$SOMAXCONN"
+            echo "WARN: The original net.core.somaxconn value will be set back when the os reboots."
+            echo "WARN:"
+        fi
+    ;;
+    FreeBSD | Darwin)
+        somaxconn=$(sysctl kern.ipc.somaxconn | awk '{print $2}')
+        if [ "$somaxconn" -lt $SOMAXCONN ]; then
+            echo "WARN:"
+            echo "WARN: the value of kern.ipc.somaxconn (=$somaxconn) is too small, please set it to a larger value using the following command."
+            echo "WARN:     sudo sysctl -w kern.ipc.somaxconn=$SOMAXCONN"
+            echo "WARN: The original kern.ipc.somaxconn value will be set back when the os reboots."
+            echo "WARN:"
+        fi
+    ;;
+esac
+
 calculate_heap_sizes()
 {
     case "`uname`" in