Skip to content

[MINOR] Handle cancellation error with HoodieMetadataTableValidator#18371

Open
lokeshj1703 wants to merge 1 commit intoapache:masterfrom
lokeshj1703:minor-14
Open

[MINOR] Handle cancellation error with HoodieMetadataTableValidator#18371
lokeshj1703 wants to merge 1 commit intoapache:masterfrom
lokeshj1703:minor-14

Conversation

@lokeshj1703
Copy link
Copy Markdown
Collaborator

Describe the issue this Pull Request addresses

Currently cancellation error is not handled in HoodieMetadataTableValidator and all spark exceptions are thrown as validation errors. The PR fixes the checks so that cancellation errors are not thrown as validation exceptions.

Summary and Changelog

Currently cancellation error is not handled in HoodieMetadataTableValidator and all spark exceptions are thrown as validation errors. The PR fixes the checks so that cancellation errors are not thrown as validation exceptions.

Impact

NA

Risk Level

Low

Documentation Update

NA

Contributor's checklist

  • Read through contributor's guide
  • Enough context is provided in the sections above
  • Adequate tests were added if applicable

@github-actions github-actions bot added the size:M PR with lines of changes in (100, 300] label Mar 23, 2026
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.11%. Comparing base (817b3ad) to head (6406d88).

Files with missing lines Patch % Lines
...e/hudi/utilities/HoodieMetadataTableValidator.java 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #18371      +/-   ##
============================================
- Coverage     68.38%   66.11%   -2.28%     
+ Complexity    27505    22394    -5111     
============================================
  Files          2428     1994     -434     
  Lines        132926   110480   -22446     
  Branches      16000    13897    -2103     
============================================
- Hits          90902    73043   -17859     
+ Misses        34964    31238    -3726     
+ Partials       7060     6199     -861     
Flag Coverage Δ
common-and-other-modules ?
hadoop-mr-java-client 45.05% <0.00%> (-0.02%) ⬇️
spark-client-hadoop-common 48.21% <0.00%> (-0.01%) ⬇️
spark-java-tests 48.72% <80.00%> (+0.02%) ⬆️
spark-scala-tests 45.41% <0.00%> (+<0.01%) ⬆️
utilities 38.54% <40.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
.../java/org/apache/hudi/exception/ExceptionUtil.java 100.00% <100.00%> (ø)
...e/hudi/utilities/HoodieMetadataTableValidator.java 65.24% <0.00%> (+0.07%) ⬆️

... and 776 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hudi-bot
Copy link
Copy Markdown
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Copy link
Copy Markdown
Contributor

@yihua yihua left a comment

Choose a reason for hiding this comment

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

🤖 This review was generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

Thanks for contributing! The cancellation-vs-validation distinction is a real issue worth fixing, and the ExceptionUtil helper is a nice reusable addition. There's one null-safety bug in the new utility that could cause an NPE at runtime, and a question about the string-match approach being tied to Spark's internal message wording — see inline comments.

Throwable cause = t;
while (cause != null) {
if (cause.getMessage().contains(errorMsg)) {
return true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 cause.getMessage() can return null when an exception is constructed without a message (e.g. new RuntimeException(anotherException)), which would throw an NPE here. Could you guard this with something like cause.getMessage() != null && cause.getMessage().contains(errorMsg)?

@@ -690,6 +691,8 @@ public boolean doMetadataTableValidation() {
} catch (SparkException sparkException) {
if (sparkException.getCause() instanceof HoodieValidationException) {
throw (HoodieValidationException) sparkException.getCause();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 The string "cancelled because SparkContext was shut down" is an internal Spark message that could silently change between Spark versions (Hudi's CI matrix already covers 3.3 through 4.0). Have you verified the wording is stable across all supported Spark versions? It might also be worth checking sparkException.getMessage() directly at the top level first, before walking nested causes, since this particular message typically surfaces at the SparkException level itself.

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

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants