-
Notifications
You must be signed in to change notification settings - Fork 29.3k
SPARK-23660: Fix exception in yarn cluster mode when application ended fast #20807
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
Changes from 2 commits
114ac05
442cfb4
5b304d1
284ed68
33ca59d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -417,8 +417,11 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| } | ||
| } | ||
|
|
||
| private def sparkContextInitialized(sc: SparkContext) = { | ||
| private def sparkContextInitialized(sc: SparkContext) = synchronized { | ||
| // Notify runDriver function that SparkContext is available | ||
| sparkContextPromise.success(sc) | ||
| // Pause the user class thread in order to make proper initialisation in runDriver function | ||
| wait() | ||
| } | ||
|
|
||
| private def registerAM( | ||
|
|
@@ -497,6 +500,8 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| // if the user app did not create a SparkContext. | ||
| throw new IllegalStateException("User did not initialize spark context!") | ||
| } | ||
| // After initialisation notify user class thread to continue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rest of the code uses American spelling ("initialization"), so this should be consistent.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed and switched to US spell checker.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should remove this comment and add one to the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved. |
||
| synchronized { notify() } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you have to do this in two places, I'd create a method (e.g.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved into |
||
| userClassThread.join() | ||
| } catch { | ||
| case e: SparkException if e.getCause().isInstanceOf[TimeoutException] => | ||
|
|
@@ -506,6 +511,8 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends | |
| finish(FinalApplicationStatus.FAILED, | ||
| ApplicationMaster.EXIT_SC_NOT_INITED, | ||
| "Timed out waiting for SparkContext.") | ||
| } finally { | ||
| synchronized { notify() } | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some other code in this class uses synchronization on
this, so I think it would be better to synchronize onsparkContextPromisein this case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used
sparkContextPromiseas lock.