From 3694c0d9e72a65ea7ab497b462f48850b138dcdd Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Lesaint?= Date: Thu, 9 Jan 2020 09:58:26 +0100 Subject: [PATCH] SONAR-12686 MaxDirectMemorySize JVM option should be defined for ES This option was set by default in ES 6.X already but we had missed it. ES sets it to half the max heap from Java code (see class JvmErgonomics) To not have to get into the complexity of interpreting options to know what is the configured max heap, we just add this option to the defaults and document it --- .../src/main/java/org/sonar/process/ProcessProperties.java | 2 +- sonar-application/build.gradle | 2 +- sonar-application/src/main/assembly/conf/sonar.properties | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java index ec4288bc663..3e5b8c3b473 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java +++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java @@ -75,7 +75,7 @@ public class ProcessProperties { SEARCH_HOST("sonar.search.host", InetAddress.getLoopbackAddress().getHostAddress()), SEARCH_PORT("sonar.search.port", "9001"), SEARCH_HTTP_PORT("sonar.search.httpPort"), - SEARCH_JAVA_OPTS("sonar.search.javaOpts", "-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError"), + SEARCH_JAVA_OPTS("sonar.search.javaOpts", "-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError"), SEARCH_JAVA_ADDITIONAL_OPTS("sonar.search.javaAdditionalOpts", ""), SEARCH_REPLICAS("sonar.search.replicas"), SEARCH_MINIMUM_MASTER_NODES("sonar.search.minimumMasterNodes"), diff --git a/sonar-application/build.gradle b/sonar-application/build.gradle index ca68d5e9457..e9a4d6d8952 100644 --- a/sonar-application/build.gradle +++ b/sonar-application/build.gradle @@ -97,7 +97,7 @@ task zip(type: Zip, dependsOn: [configurations.compile]) { from file('src/main/assembly/conf/sonar.properties') filter(ReplaceTokens, tokens: [ 'searchDefaultHeapSize': '512MB', - 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError', + 'searchJavaOpts' : '-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError', 'ceDefaultHeapSize' : '512MB', 'ceJavaOpts' : '-Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError', 'webDefaultHeapSize' : '512MB', diff --git a/sonar-application/src/main/assembly/conf/sonar.properties b/sonar-application/src/main/assembly/conf/sonar.properties index 0559fbc1fef..6ce66482775 100644 --- a/sonar-application/src/main/assembly/conf/sonar.properties +++ b/sonar-application/src/main/assembly/conf/sonar.properties @@ -251,7 +251,8 @@ #-------------------------------------------------------------------------------------------------- # ELASTICSEARCH # Elasticsearch is used to facilitate fast and accurate information retrieval. -# It is executed in a dedicated Java process. Default heap size is @searchDefaultHeapSize@. +# It is executed in a dedicated Java process. Default maximum heap size is @searchDefaultHeapSize@. +# It is recommended to also set MaxDirectMemorySize (-XX:MaxDirectMemorySize) and set it to half the maximum heap size. # # -------------------------------------------------- # Word of caution for Linux users on 64bits systems -- 2.39.5