Skip to content

Commit d8bb413

Browse files
authored
Configure heap dump path out of the box
The JVM defaults to dumping the heap to the working directory of Elasticsearch. For the RPM and Debian packages, this location is /usr/share/elasticsearch. This directory is not writable by the elasticsearch user, so by default heap dumps in this situation are lost. This commit modifies the packaging for the RPM and Debian packages to set the heap dump path to /var/lib/elasticsearch as the default location for dumping the heap. This location is writable by the elasticsearch user by default. We add documentation of this important setting if /var/lib/elasticsearch is not suitable for receiving heap dumps. Relates #26755
1 parent 2e63a13 commit d8bb413

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

distribution/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,12 @@ Map<String, String> expansionsForDistribution(distributionType) {
537537
'heap.min': defaultHeapSize,
538538
'heap.max': defaultHeapSize,
539539

540+
'heap.dump.path': [
541+
'deb': "-XX:HeapDumpPath=/var/lib/elasticsearch",
542+
'rpm': "-XX:HeapDumpPath=/var/lib/elasticsearch",
543+
'def': "#-XX:HeapDumpPath=/heap/dump/path"
544+
],
545+
540546
'stopping.timeout': [
541547
'rpm': 86400,
542548
],

distribution/src/main/resources/config/jvm.options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080

8181
# specify an alternative path for heap dumps
8282
# ensure the directory exists and has sufficient space
83-
#-XX:HeapDumpPath=${heap.dump.path}
83+
${heap.dump.path}
8484

8585
## GC logging
8686

docs/reference/setup/important-settings.asciidoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ configured before going into production.
1212
* <<network.host,`network.host`>>
1313
* <<unicast.hosts,`discovery.zen.ping.unicast.hosts`>>
1414
* <<minimum_master_nodes,`discovery.zen.minimum_master_nodes`>>
15+
* <<heap-dump-path,JVM heap dump path>>
1516

1617
[float]
1718
[[path-settings]]
@@ -180,3 +181,23 @@ nodes should be set to `(3 / 2) + 1` or `2`:
180181
discovery.zen.minimum_master_nodes: 2
181182
--------------------------------------------------
182183

184+
[float]
185+
[[heap-dump-path]]
186+
=== JVM heap dump path
187+
188+
The <<rpm,RPM>> and <<deb,Debian>> package distributions default to configuring
189+
the JVM to dump the heap on out of memory exceptions to
190+
`/var/lib/elasticsearch`. If this path is not suitable for storing heap dumps,
191+
you should modify the entry `-XX:HeapDumpPath=/var/lib/elasticsearch` in
192+
<<jvm-options,`jvm.options`>> to an alternate path. If you specify a filename
193+
instead of a directory, the JVM will repeatedly use the same file; this is one
194+
mechanism for preventing heap dumps from accumulating in the heap dump path.
195+
Alternatively, you can configure a scheduled task via your OS to remove heap
196+
dumps that are older than a configured age.
197+
198+
Note that the archive distributions do not configure the heap dump path by
199+
default. Instead, the JVM will default to dumping to the working directory for
200+
the Elasticsearch process. If you wish to configure a heap dump path, you should
201+
modify the entry `#-XX:HeapDumpPath=/heap/dump/path` in
202+
<<jvm-options,`jvm.options`>> to remove the comment marker `#` and to specify an
203+
actual path.

0 commit comments

Comments
 (0)