From 511792772ae7c6bfb0ac68f39b39bfcc962e65b9 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 28 Jul 2025 15:31:56 -0400 Subject: [PATCH] ESQL: Stabilize heap attack test In some contexts ESQL's HeapAttack tests were failing because the TranslogWriter keeps a map with the contents of the documents in it around. But only when assertions are enabled. Fun. This flushes the map away, preventing the odd OOM we were seeing in the HeapAttack tests. --- .../xpack/esql/heap_attack/HeapAttackIT.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java index 4ed79024a19f9..82419d03d4259 100644 --- a/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java +++ b/test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java @@ -894,7 +894,6 @@ private void initGiantTextField(int docs) throws IOException { } } } - logger.info("loading many documents with one big text field - docs per bulk {}", docsPerBulk); int fieldSize = Math.toIntExact(ByteSizeValue.ofMb(5).getBytes()); @@ -1064,6 +1063,15 @@ private void bulk(String name, String bulk) throws IOException { ); Response response = client().performRequest(request); assertThat(entityAsMap(response), matchesMap().entry("errors", false).extraOk()); + + /* + * Flush after each bulk to clear the test-time seenSequenceNumbers Map in + * TranslogWriter. Without this the server will OOM from time to time keeping + * stuff around to run assertions on. + */ + request = new Request("POST", "/" + name + "/_flush"); + response = client().performRequest(request); + assertThat(entityAsMap(response), matchesMap().entry("_shards", matchesMap().extraOk().entry("failed", 0)).extraOk()); } private void initIndex(String name, String bulk) throws IOException {