opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.47k stars 1.74k forks source link

[BUG] org.opensearch.action.search.SearchResponseTests.testFromXContentWithUnregisteredSearchExtBuilders is flaky #11471

Open ketanv3 opened 9 months ago

ketanv3 commented 9 months ago

Describe the bug The following test cases are flaky:

Caused by: org.yaml.snakeyaml.error.YAMLException: The incoming YAML document exceeds the limit: 3145728 code points.
    at app//org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:317)
    at app//org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:238)
    at app//org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:637)
    at app//org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:161)
    at app//org.yaml.snakeyaml.parser.ParserImpl.getEvent(ParserImpl.java:170)
    at app//com.fasterxml.jackson.dataformat.yaml.YAMLParser.nextToken(YAMLParser.java:429)
    ... 81 more

To Reproduce It happens when the search response is too large for the YAML parser (3 MB limit).

./gradlew ':server:test' --tests "org.opensearch.action.search.SearchResponseTests.testFromXContentWithUnregisteredSearchExtBuilders" -Dtests.seed=F439DE99AECABF2F -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=id-ID -Dtests.timezone=America/Indiana/Knox -Druntime.java=21
./gradlew ':server:test' --tests "org.opensearch.search.GenericSearchExtBuilderTests.testFromXContentWithUnregisteredSearchExtBuilders" -Dtests.seed=F439DE99AECABF2F -Dtests.security.manager=true -Dtests.jvm.argline="-XX:TieredStopAtLevel=1 -XX:ReservedCodeCacheSize=64m" -Dtests.locale=ar-DZ -Dtests.timezone=Indian/Comoro -Druntime.java=21

Expected behavior The tests should always pass

Plugins Standard distribution

Screenshots N/A

Host/Environment (please complete the following information) CI (Jenkins)

Additional context Failing build: https://build.ci.opensearch.org/job/gradle-check/30833/

ketanv3 commented 9 months ago

Here's the output of the search response that failed to parse due to its very large size: SearchResponse_testFromXContentWithUnregisteredSearchExtBuilders.json

This happens due to very deeply nested aggregations in the search response. Test aggregations are created recursively up to some maximum depth (here), which can lead to exponentially large payloads on rare occasions. We can lower the maximum depth from 5 to 4, which should help us not go past the 3 MB parsing limit for YAML.