From 04f37dfcc2063f9e7c627e7a52d647758469b551 Mon Sep 17 00:00:00 2001 From: Armin Braun Date: Mon, 16 Oct 2023 15:04:33 +0200 Subject: [PATCH] Use pooled Netty allocator in tests by default (#100877) We mostly run our tests with less than 1G of heap per JVM. This means that we will use the unpooled Netty allocator in most tests, losing us a lot of leak coverage in internal cluster tests (mostly for inbound buffers). Unless otherwise specified by tests, we should force the use of our standard allocator by default to get a higher chance of catching leaks in internalClusterTests in particular. --- .../src/main/java/org/elasticsearch/test/ESTestCase.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java index 9ccfbd2e25ca6..c7e74bde890f8 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java @@ -323,6 +323,11 @@ private static void setTestSysProps() { // Enable Netty leak detection and monitor logger for logged leak errors System.setProperty("io.netty.leakDetection.level", "paranoid"); + if (System.getProperty("es.use_unpooled_allocator") == null) { + // unless explicitly forced to unpooled, always test with the pooled allocator to get the best possible coverage from Netty's + // leak detection which does not cover simple unpooled heap buffers + System.setProperty("es.use_unpooled_allocator", "false"); + } // We have to disable setting the number of available processors as tests in the same JVM randomize processors and will step on each // other if we allow them to set the number of available processors as it's set-once in Netty.