From 5adb595f2b96e7f33ec9fa9f76d686e23f4120e9 Mon Sep 17 00:00:00 2001 From: Jan Was Date: Fri, 6 Aug 2021 13:41:51 +0200 Subject: [PATCH] Set higher open files limit in init script Make sure the init script installed by the RPM package is setting the maximum number of open files as recommended in the documentation. If the value is too low, a warning would be logged. But if there's a large number of connectors present, the server would fail to start. Any limits set in `/etc/security/limits.conf` would override these defaults. --- .../src/main/resources/dist/etc/init.d/trino | 10 ++++++++++ docs/src/main/sphinx/installation/deployment.rst | 3 +++ 2 files changed, 13 insertions(+) diff --git a/core/trino-server-rpm/src/main/resources/dist/etc/init.d/trino b/core/trino-server-rpm/src/main/resources/dist/etc/init.d/trino index 68b05a2fca4d..4b3a8536b86b 100644 --- a/core/trino-server-rpm/src/main/resources/dist/etc/init.d/trino +++ b/core/trino-server-rpm/src/main/resources/dist/etc/init.d/trino @@ -37,6 +37,16 @@ CONFIGURATION=( --server-log-file "${SERVER_LOG_FILE:-/var/log/trino/server.log}" ) +# As defined in the requirements: https://trino.io/docs/current/installation/deployment.html#requirements +files_limit=131072 +if current_limit=$(ulimit -Hn) && [ "${files_limit}" -lt "${current_limit}" ]; then + files_limit="${current_limit}" +fi +if max_limit=$(cat /proc/sys/fs/nr_open) && [ "${files_limit}" -gt "${max_limit}" ]; then + files_limit="${max_limit}" +fi +ulimit -n "${files_limit}" + declare -A CONFIG_ENV # Don't need shellcheck to follow env.sh # shellcheck disable=1091 diff --git a/docs/src/main/sphinx/installation/deployment.rst b/docs/src/main/sphinx/installation/deployment.rst index 629514e7d951..2fe5d983ba6a 100644 --- a/docs/src/main/sphinx/installation/deployment.rst +++ b/docs/src/main/sphinx/installation/deployment.rst @@ -26,6 +26,9 @@ Linux operating system trino soft nofile 131072 trino hard nofile 131072 +.. + These values are used in core/trino-server-rpm/src/main/resources/dist/etc/init.d/trino + .. _requirements-java: Java runtime environment