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

[SPARK-38613][CORE] Change the exception type thrown by PushBlockStreamCallback#abortIfNecessary from RuntimeException to IllegalStateException #35923

Closed
wants to merge 3 commits into from

Conversation

LuciferYang
Copy link
Contributor

@LuciferYang LuciferYang commented Mar 21, 2022

What changes were proposed in this pull request?

This pr change the exception type thrown by PushBlockStreamCallback#abortIfNecessary from RuntimeException to IllegalStateException and fixed the corresponding test case.

In addition, this PR fixes the bug of testWritingPendingBufsIsAbortedImmediatelyDuringComplete in RemoteBlockPushResolverSuite. RuntimeException throw by

RemoteBlockPushResolver.PushBlockStreamCallback callback2 =
(RemoteBlockPushResolver.PushBlockStreamCallback) pushResolver.receiveBlockDataAsStream(
new PushBlockStream(TEST_APP, 1, 0, 0, 5, 0, 0));

before this pr, but the test case expects it to be thrown by

try {
callback.onComplete(callback.getID());
} catch (Throwable t) {
assertEquals("IOExceptions exceeded the threshold when merging shufflePush_0_0_0",
t.getMessage());
throw t;
}

Why are the changes needed?

The RuntimeException is too broad, it should be specific.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Pass GA and fix related UTs

@LuciferYang
Copy link
Contributor Author

LuciferYang commented Mar 21, 2022

cc @otterc, also ping @dongjoon-hyun @HyukjinKwon @srowen

@LuciferYang
Copy link
Contributor Author

On the other hand, should we uniformly use Assert.assertThrows to replace @Test(expected = Exception.class)? My idea is:

Assert.assertThrows can accurately ensure a statement will throw an Exception, but @Test(expected = Exception.class) only ensure the current Test method will throw the corresponding Exception.

@srowen @dongjoon-hyun @HyukjinKwon If necessary, I will file a new Jira.

@github-actions github-actions bot added the CORE label Mar 21, 2022
@srowen
Copy link
Member

srowen commented Mar 21, 2022

I wouldn't change everything, but change cases where we suspect that it's catching too much.

The problem here is really looking for RuntimeException, not the scope. That is too broad. Is something more specific thrown that we can catch without catching other stuff?

@LuciferYang
Copy link
Contributor Author

The exception thrown from

private void abortIfNecessary() {
if (partitionInfo.shouldAbort(mergeManager.ioExceptionsThresholdDuringMerge)) {
deferredBufs = null;
throw new RuntimeException(String.format("%s when merging %s",
ErrorHandler.BlockPushErrorHandler.IOEXCEPTIONS_EXCEEDED_THRESHOLD_PREFIX,
streamId));
}
}

Only RuntimeException is thrown here now, no more specific type. BlockPushNonFatalFailure is not suitable here, may be necessary to define a new type.

@srowen
Copy link
Member

srowen commented Mar 21, 2022

We could fix that. This should really be something more specific - IllegalStateException? this is just the problem it causes, using RuntimeException

@LuciferYang
Copy link
Contributor Author

We could fix that. This should really be something more specific - IllegalStateException? this is just the problem it causes, using RuntimeException

ok

@LuciferYang LuciferYang changed the title [SPARK-38613][TESTS] Fix testWritingPendingBufsIsAbortedImmediatelyDuringComplete in RemoteBlockPushResolverSuite [SPARK-38613][CORE] Change the exception type thrown by PushBlockStreamCallback#abortIfNecessary from RuntimeException to IllegalStateException Mar 22, 2022
@LuciferYang
Copy link
Contributor Author

@srowen b08a255 change exception type from RuntimeException to IllegalStateException

@@ -756,12 +756,12 @@ private void writeDeferredBufs() throws IOException {
}

/**
* This throws RuntimeException if the number of IOExceptions have exceeded threshold.
* This throws IllegalStateException if the number of IOExceptions have exceeded threshold.
Copy link
Member

Choose a reason for hiding this comment

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

No big deal but this can be * @throws IllegalStateException if ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

4583b22 fix this

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

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

Looks OK pending tests

@srowen srowen closed this in 2eae3db Mar 23, 2022
@srowen
Copy link
Member

srowen commented Mar 23, 2022

Merged to master

@LuciferYang
Copy link
Contributor Author

thanks @srowen

@LuciferYang LuciferYang deleted the SPARK-38613 branch October 23, 2023 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants