Skip to content

Commit 774b022

Browse files
authored
ESQL: Stabilize heap attack test (#132045) (#132285)
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.
1 parent 3bcd9a1 commit 774b022

File tree

1 file changed

+20
-2
lines changed
  • test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack

1 file changed

+20
-2
lines changed

test/external-modules/esql-heap-attack/src/javaRestTest/java/org/elasticsearch/xpack/esql/heap_attack/HeapAttackIT.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,17 @@ private void initManyBigFieldsIndex(int docs, String type) throws IOException {
884884
}
885885

886886
private void initGiantTextField(int docs) throws IOException {
887-
logger.info("loading many documents with one big text field");
888-
int docsPerBulk = 3;
887+
int docsPerBulk = 10;
888+
for (Map<?, ?> nodeInfo : getNodesInfo(adminClient()).values()) {
889+
for (Object module : (List<?>) nodeInfo.get("modules")) {
890+
Map<?, ?> moduleInfo = (Map<?, ?>) module;
891+
final String moduleName = moduleInfo.get("name").toString();
892+
if (moduleName.startsWith("serverless-")) {
893+
docsPerBulk = 3;
894+
}
895+
}
896+
}
897+
logger.info("loading many documents with one big text field - docs per bulk {}", docsPerBulk);
889898
int fieldSize = Math.toIntExact(ByteSizeValue.ofMb(5).getBytes());
890899

891900
Request request = new Request("PUT", "/bigtext");
@@ -1052,6 +1061,15 @@ private void bulk(String name, String bulk) throws IOException {
10521061
);
10531062
Response response = client().performRequest(request);
10541063
assertThat(entityAsMap(response), matchesMap().entry("errors", false).extraOk());
1064+
1065+
/*
1066+
* Flush after each bulk to clear the test-time seenSequenceNumbers Map in
1067+
* TranslogWriter. Without this the server will OOM from time to time keeping
1068+
* stuff around to run assertions on.
1069+
*/
1070+
request = new Request("POST", "/" + name + "/_flush");
1071+
response = client().performRequest(request);
1072+
assertThat(entityAsMap(response), matchesMap().entry("_shards", matchesMap().extraOk().entry("failed", 0)).extraOk());
10551073
}
10561074

10571075
private void initIndex(String name, String bulk) throws IOException {

0 commit comments

Comments
 (0)