Skip to content

YARN-12007. Avoid intermediate overflow in YARN unit conversion - #8817

Open
gerashegalov wants to merge 1 commit into
apache:trunkfrom
gerashegalov:YARN-12007
Open

gerashegalov wants to merge 1 commit into
apache:trunkfrom
gerashegalov:YARN-12007

Conversation

@gerashegalov

Copy link
Copy Markdown
Contributor

Description of PR

UnitsConversionUtil.convert can overflow during intermediate multiplication even when the final result fits in a long. For example, converting Long.MAX_VALUE from p to G returns 2 instead of 0, while converting 10000 from P to Pi throws instead of returning 8881.

Use checked long arithmetic for the common path and BigInteger when an intermediate overflows. Reject only a final result outside long. Zero values return before multiplication, after unit validation. This change does not alter compare.

Contains content generated by OpenAI Codex.

How was this patch tested?

  • Targeted Maven tests for TestUnitsConversionUtil, TestResourceUtils, TestTimelineServiceHelper, and TestResourcePBImpl: 33 tests passed, no failures or errors.
  • git diff --check passed.
  • An independent arithmetic review checked all 225 unit pairs across 16,461 inputs with no mismatches.

For code changes:

  • Does the title of this PR start with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: Have the integration tests been executed and the endpoint declared according to the connector-specific documentation? Note: Automated CI testing doesn't cover all cases so manual testing with cloud storage is still required. (Not applicable.)
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0? (No new dependencies.)
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files? (Not applicable.)

AI Tooling

If an AI tool was used:

Contains content generated by OpenAI Codex.

Signed-off-by: Gera Shegalov <gshegalov@nvidia.com>
@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 18m 50s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 54m 48s trunk passed
+1 💚 compile 1m 11s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 compile 1m 10s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 checkstyle 0m 56s trunk passed
+1 💚 mvnsite 1m 13s trunk passed
+1 💚 javadoc 1m 6s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 1m 3s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 3m 1s trunk passed
+1 💚 shadedclient 36m 26s branch has no errors when building and testing our client artifacts.
-0 ⚠️ patch 37m 2s Used diff version of patch file. Binary files and potentially other changes not applied. Please rebase and squash commits if necessary.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 44s the patch passed
+1 💚 compile 0m 40s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javac 0m 40s the patch passed
+1 💚 compile 0m 42s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 javac 0m 42s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 24s the patch passed
+1 💚 mvnsite 0m 46s the patch passed
+1 💚 javadoc 0m 34s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 34s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 2m 43s the patch passed
+1 💚 shadedclient 35m 59s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 0m 58s hadoop-yarn-api in the patch passed.
+1 💚 asflicense 0m 36s The patch does not generate ASF License warnings.
163m 52s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8817/1/artifact/out/Dockerfile
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 205b64940d51 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 86e6c20
Default Java Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8817/1/testReport/
Max. process+thread count 591 (vs. ulimit of 10000)
modules C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8817/1/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants