Skip to content

Conversation

@zsxwing
Copy link
Member

@zsxwing zsxwing commented May 11, 2017

What changes were proposed in this pull request?

This PR adds an error parameter to TaskContextImpl.markTaskCompleted to propagate the original error.

It also fixes an issue that TaskCompletionListenerException.getMessage doesn't include previousError.

How was this patch tested?

New unit tests.

}
// Call the task completion callbacks. If "markTaskCompleted" is called twice, the second
// one is no-op.
context.markTaskCompleted(None)
Copy link
Member Author

Choose a reason for hiding this comment

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

Just add try...finally to wrap this line and fix the style

Copy link
Contributor

Choose a reason for hiding this comment

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

We end up calling markTaskCompleted twice when there is an exception thrown, right ?
Perhaps do this one when no Throwable is thrown.

Copy link
Member Author

Choose a reason for hiding this comment

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

We end up calling markTaskCompleted twice when there is an exception thrown, right ?

Yes.

Perhaps do this one when no Throwable is thrown.

Then if context.markTaskCompleted(None) throws an exception, context.markTaskFailed(e) will be called, so TaskFailureListener may be called after TaskCompletionListener. This is a slight behavior change. Not sure if it's safe. Someone may depend on the order of calling listeners?

Copy link
Contributor

Choose a reason for hiding this comment

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

What I meant was, when there is an exception is throw, there will be two invocations of context.markTaskCompleted.
One with Throwable passed in, and another with None.

This would be confusing to the listeners - no ?

Copy link
Member Author

Choose a reason for hiding this comment

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

@mridulm there is a completed flag in markTaskCompleted.

extends RuntimeException {

override def getMessage: String = {
if (errorMessages.size == 1) {
Copy link
Member Author

@zsxwing zsxwing May 11, 2017

Choose a reason for hiding this comment

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

The problem here is

if (...) { ... } else {...} +
{...}

is equivalent to

if (...) { ... } else {   {...} + {...}  }

which is not the intention.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch !
Btw, file name should probably have been taskListeners.scala (unrelated to this PR) ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess it's because it's not a class name. cc @rxin since you added this file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Aside: Was just curious about the naming - interesting. Is this common pattern in spark code ?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a common pattern in scala.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thx for clarifying !

@SparkQA
Copy link

SparkQA commented May 11, 2017

Test build #76762 has finished for PR 17942 at commit 5c50068.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@tdas
Copy link
Contributor

tdas commented May 12, 2017

LGTM. Should merge this soon. @mridulm any thoughts.

memoryManager.synchronized { memoryManager.notifyAll() }
}
// Call the task completion callbacks. If "markTaskCompleted" is called twice, the second
// one is no-op.
Copy link
Contributor

Choose a reason for hiding this comment

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

Missed this comment.
LGTM. Thanks for clarifying @zsxwing

@zsxwing
Copy link
Member Author

zsxwing commented May 12, 2017

Thanks! Merging to master and 2.2.

asfgit pushed a commit that referenced this pull request May 12, 2017
… the original error

## What changes were proposed in this pull request?

This PR adds an `error` parameter to `TaskContextImpl.markTaskCompleted` to propagate the original error.

It also fixes an issue that `TaskCompletionListenerException.getMessage` doesn't include `previousError`.

## How was this patch tested?

New unit tests.

Author: Shixiong Zhu <[email protected]>

Closes #17942 from zsxwing/SPARK-20702.

(cherry picked from commit 7d6ff39)
Signed-off-by: Shixiong Zhu <[email protected]>
@asfgit asfgit closed this in 7d6ff39 May 12, 2017
@zsxwing zsxwing deleted the SPARK-20702 branch May 12, 2017 17:53
robert3005 pushed a commit to palantir/spark that referenced this pull request May 19, 2017
… the original error

## What changes were proposed in this pull request?

This PR adds an `error` parameter to `TaskContextImpl.markTaskCompleted` to propagate the original error.

It also fixes an issue that `TaskCompletionListenerException.getMessage` doesn't include `previousError`.

## How was this patch tested?

New unit tests.

Author: Shixiong Zhu <[email protected]>

Closes apache#17942 from zsxwing/SPARK-20702.
liyichao pushed a commit to liyichao/spark that referenced this pull request May 24, 2017
… the original error

## What changes were proposed in this pull request?

This PR adds an `error` parameter to `TaskContextImpl.markTaskCompleted` to propagate the original error.

It also fixes an issue that `TaskCompletionListenerException.getMessage` doesn't include `previousError`.

## How was this patch tested?

New unit tests.

Author: Shixiong Zhu <[email protected]>

Closes apache#17942 from zsxwing/SPARK-20702.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants