Repository navigation
Increase the maximum JSON string length in the OpenSearch source client to 64 MB - #7222
Davidding4718 wants to merge 1 commit into
Conversation
✅ License Header Check PassedAll newly added files have proper license headers. Great work! 🎉 |
PR Reviewer Guide 🔍(Review updated until commit 7a41c78)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit c0db53d |
c0db53d to
7e57892
Compare
|
Persistent review updated to latest commit 7e57892 |
| * Matches the limit used for events in JacksonEvent so that documents which can be | ||
| * represented as an Event can also be read from the source cluster. | ||
| */ | ||
| static final int MAX_JSON_STRING_LENGTH = 64 * 1024 * 1024; |
There was a problem hiding this comment.
Thanks @Davidding4718 for the contribution and the clear write-up! JsonFactories.MAX_JSON_STRING_LENGTH from #7167 already holds this 64 MB value, and the opensearch plugin depends on data-prepper-api. Could we use it here instead of a second constant?
There was a problem hiding this comment.
Thanks! I will remove the local constant and reuse.
| import static org.hamcrest.Matchers.instanceOf; | ||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
|
||
| class OpenSearchClientFactoryJsonpMapperTest { |
There was a problem hiding this comment.
These tests check the helper methods, but not that the clients use them. I switched the REST, AWS and Elasticsearch transports back to the default mapper one by one, and every test still passed. Could you add a test per transport that checks the client's mapper limit?
There was a problem hiding this comment.
Thanks for verifying that. I will add assertions.
|
Optional, @Davidding4718: I tested this against a real OpenSearch cluster and it works. A page of 5 documents with 25M characters each still fails on the REST client with |
Thanks for testing this end to end! I saw the same result locally against OpenSearch 2.19.1 with PIT: a single document with a 20,054,016-character field fails on Agreed that the response size limit is worth documenting. It's separate from the string limit: for very large documents, |
…nt to 64 MB The opensearch source deserializes search responses using JacksonJsonpMapper instances created with Jackson's default StreamReadConstraints, which limit string values to 20,000,000 characters. Documents with a larger string field fail with StreamConstraintsException before an Event is created, and the source retries the index indefinitely. Raise the limit to 64 MB on the OpenSearch (RestClient and AwsSdk2) and Elasticsearch client mappers, matching the limit used by JacksonEvent (opensearch-project#7146). Signed-off-by: Siqi Ding <dingdd@amazon.com>
7e57892 to
7a41c78
Compare
|
Persistent review updated to latest commit 7a41c78 |
PR Code Suggestions ✨Explore these optional code suggestions:
|
srikanthpadakanti
left a comment
There was a problem hiding this comment.
Thanks for the fix and for addressing both comments, @Davidding4718. The shared constant is reused and every client path is now covered by a test. Looks good to me.
|
@Davidding4718 , Thank you for this contribution! It looks good for the |
Description
#7146 raised Jackson's
StreamReadConstraints.maxStringLengthto 64 MB forJacksonEvent. However, theopensearchsource deserializes search responses (PIT / search_after / scroll) with its ownJacksonJsonpMapperinstances, created via the no-arg constructor inOpenSearchClientFactory. Those mappers still use Jackson's default limit of 20,000,000 characters, so a document with a large string field fails before an Event is ever built:Because this happens on read,
PitWorkerretries the index indefinitely and the pipeline makes no progress.Changes
OpenSearchClientFactorynow creates its mappers viacreateJacksonJsonpMapper()/createElasticsearchJacksonJsonpMapper(), which keep each client's defaultJacksonJsonpMapperconfiguration and only raisemaxStringLengthon the mapper'sJsonFactoryto 64 MB (same asJacksonEvent).AwsSdk2Transport(SigV4 / AOS / AOSS),RestClientTransport, and Elasticsearch client paths.JacksonJsonpMapperbuilds itsJacksonJsonProviderfromobjectMapper.getFactory(), so the constraint applies to response parsing.Testing
New
OpenSearchClientFactoryJsonpMapperTest:JacksonJsonpMapperrejects a 20,000,001-char string (reproduces the issue)./gradlew :data-prepper-plugins:opensearch:test --tests 'org.opensearch.dataprepper.plugins.source.opensearch.*'and checkstyle pass.Open questions
Issues Resolved
Follow-up to #7146.
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.