Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check UTF16 string size before converting to String to avoid OOME #7963

Merged
merged 4 commits into from
Jun 29, 2023

Conversation

imRishN
Copy link
Member

@imRishN imRishN commented Jun 8, 2023

Description

Node can drop out for OutOfMemory errors other than the VM OutOfMemory which comes from the implementation limits of StringUTF16.

java.lang.OutOfMemoryError: UTF16 String size is 1089861360, should be less than 1073741823

This PR attempts to pre check the size and throw an exception proactively before trying a conversion.

Related Issues

Resolves #1651

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed per the DCO using --signoff
  • Commit changes are listed out in CHANGELOG.md file (See: Changelog)

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.search.backpressure.SearchBackpressureIT.testSearchShardTaskCancellationWithHighCpu

@codecov
Copy link

codecov bot commented Jun 8, 2023

Codecov Report

Merging #7963 (be82717) into main (976048d) will increase coverage by 0.03%.
The diff coverage is 89.47%.

@@             Coverage Diff              @@
##               main    #7963      +/-   ##
============================================
+ Coverage     70.87%   70.91%   +0.03%     
- Complexity    56904    56908       +4     
============================================
  Files          4756     4757       +1     
  Lines        269064   269106      +42     
  Branches      39392    39396       +4     
============================================
+ Hits         190710   190831     +121     
+ Misses        62285    62151     -134     
- Partials      16069    16124      +55     
Impacted Files Coverage Δ
...nsearch/action/search/ArraySearchPhaseResults.java 90.90% <ø> (ø)
...java/org/opensearch/action/search/SearchPhase.java 80.00% <0.00%> (-20.00%) ⬇️
...g/opensearch/action/search/SearchPhaseContext.java 66.66% <ø> (ø)
...g/opensearch/action/search/SearchPhaseResults.java 71.42% <ø> (ø)
...a/org/opensearch/plugins/SearchPipelinePlugin.java 0.00% <0.00%> (ø)
...earch/action/search/AbstractSearchAsyncAction.java 77.94% <75.00%> (-1.00%) ⬇️
.../java/org/opensearch/search/pipeline/Pipeline.java 86.04% <75.00%> (-1.80%) ⬇️
...pensearch/common/bytes/AbstractBytesReference.java 84.66% <100.00%> (+0.58%) ⬆️
...ch/action/search/CanMatchPreFilterSearchPhase.java 93.44% <100.00%> (-3.23%) ⬇️
...va/org/opensearch/action/search/DfsQueryPhase.java 90.24% <100.00%> (ø)
... and 10 more

... and 470 files with indirect coverage changes

Copy link
Contributor

@BhumikaSaini-Amazon BhumikaSaini-Amazon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

Few minor comments and we should add a unit test

@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2023

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.search.backpressure.SearchBackpressureIT.testSearchTaskCancellationWithHighCpu

@imRishN imRishN requested a review from sachinpkale as a code owner June 27, 2023 12:55
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@imRishN imRishN requested a review from reta June 27, 2023 13:41
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testNodeDropWithOngoingReplication

Signed-off-by: Rishab Nahata <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testNodeDropWithOngoingReplication
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testDropPrimaryDuringReplication
      1 org.opensearch.indices.replication.SegmentReplicationIT.testScrollCreatedOnReplica

@dblock
Copy link
Member

dblock commented Jun 28, 2023

@Bukhtawar @reta ya'll good with this as is now?

Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testNodeDropWithOngoingReplication
      1 org.opensearch.indices.replication.SegmentReplicationIT.testScrollCreatedOnReplica

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.remotestore.SegmentReplicationUsingRemoteStoreIT.testNodeDropWithOngoingReplication

@Bukhtawar Bukhtawar merged commit 544b1ca into opensearch-project:main Jun 29, 2023
@imRishN imRishN added the backport 2.x Backport to 2.x branch label Jun 29, 2023
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-7963-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 544b1cac97a848479f2355e11e1a2c18b40e8201
# Push it to GitHub
git push --set-upstream origin backport/backport-7963-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7963-to-2.x.

imRishN added a commit to imRishN/OpenSearch that referenced this pull request Jun 29, 2023
…ensearch-project#7963)

* Check UTF16 string size before converting to string to avoid OOME

Signed-off-by: Rishab Nahata <[email protected]>
@reta
Copy link
Collaborator

reta commented Jun 29, 2023

@imRishN could you please submit manual backport for 2.x? thank you is there already: #8344

reta pushed a commit that referenced this pull request Jun 29, 2023
) (#8344)

* Check UTF16 string size before converting to string to avoid OOME

Signed-off-by: Rishab Nahata <[email protected]>
baba-devv pushed a commit to baba-devv/OpenSearch that referenced this pull request Jul 29, 2023
…ensearch-project#7963)

* Check UTF16 string size before converting to string to avoid OOME

Signed-off-by: Rishab Nahata <[email protected]>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
…ensearch-project#7963)

* Check UTF16 string size before converting to string to avoid OOME

Signed-off-by: Rishab Nahata <[email protected]>
Signed-off-by: Shivansh Arora <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node drops out with OutOfMemoryError for reasons other than the VM having run out of memory
8 participants