Skip to content

Commit 5cfc279

Browse files
authored
ESQL: Stabilize heap attack test (#132045) (#132286)
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 7c6d6db commit 5cfc279

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
@@ -882,8 +882,17 @@ private void initManyBigFieldsIndex(int docs, String type) throws IOException {
882882
}
883883

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

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

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

0 commit comments

Comments
 (0)