Skip to content

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented Oct 28, 2025

When a linux process dies and the core process memory is dumped, which parts of the memory to output are controlled by the coredump filter. By default the JVM dumps anonymous memory (ie heap and direct memory) and file-backed memory (ie mmaps), and private huge pages. However, the default of dumping file-backed memory for Elasticsearch is problematic; these can be enormous, and they also aren't very useful since the indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit file-backed memory from coredumps. Although the JVM has diagnostic VM options for controlling the filter, they end up causing the filter to be inherited, which is from the server CLI, another Java process, which has the file-backed memory bits set. Instead of using the JVM options we set it via the special proc filesystem.

When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
@rjernst rjernst requested a review from a team as a code owner October 28, 2025 23:32
@rjernst rjernst added >refactoring :Core/Infra/Node Lifecycle Node startup, bootstrapping, and shutdown auto-backport Automatically create backport pull requests when merged branch:9.2 branch:9.1 branch:8.19 labels Oct 28, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

@rjernst
Copy link
Member Author

rjernst commented Oct 28, 2025

Note for reviewers: there isn't any easy way to test this. Ideally we could have a packaging test, but the process id we have there is the CLI. So we'll need to look at children of the CLI...

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One little fix needed (possibly) but LGTM

// which is the server CLI, which is also a JVM so it has these bits set. Thus, we set it explicitly.
// See https://man7.org/linux/man-pages/man5/core.5.html for more info on the relevant bits of the filter
try {
Files.writeString(Paths.get("/proc/self/coredump_filter"), "0x23");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this either needs a @SuppressForbidden or using and alternative (PathUtils?)

@rjernst rjernst merged commit 7d4c25d into elastic:main Oct 31, 2025
34 checks passed
@rjernst rjernst deleted the startup/core_dump_filter2 branch October 31, 2025 13:09
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Oct 31, 2025
When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
rjernst added a commit to rjernst/elasticsearch that referenced this pull request Oct 31, 2025
When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.2
8.19
9.1

rjernst added a commit to rjernst/elasticsearch that referenced this pull request Oct 31, 2025
When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
elasticsearchmachine pushed a commit that referenced this pull request Oct 31, 2025
When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
elasticsearchmachine pushed a commit that referenced this pull request Oct 31, 2025
When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
elasticsearchmachine pushed a commit that referenced this pull request Oct 31, 2025
When a linux process dies and the core process memory is dumped, which
parts of the memory to output are controlled by the coredump filter. By
default the JVM dumps anonymous memory (ie heap and direct memory) and
file-backed memory (ie mmaps), and private huge pages. However, the
default of dumping file-backed memory for Elasticsearch is problematic;
these can be enormous, and they also aren't very useful since the
indices will likely be available when investigating the crash.

This commit sets the coredump filter when running on Linux to omit
file-backed memory from coredumps. Although the JVM has diagnostic VM
options for controlling the filter, they end up causing the filter to be
inherited, which is from the server CLI, another Java process, which has
the file-backed memory bits set. Instead of using the JVM options we
set it via the special proc filesystem.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Automatically create backport pull requests when merged :Core/Infra/Node Lifecycle Node startup, bootstrapping, and shutdown >refactoring Team:Core/Infra Meta label for core/infra team v8.19.7 v9.1.7 v9.2.1 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants