-
Notifications
You must be signed in to change notification settings - Fork 28.5k
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-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode #6083
Conversation
…xt in YARN-cluster mode Added a simple checking for SparkContext. Also added two rational checking against null at AM object.
… in YARN-cluster mode Removed unnecessary line.
…xt in YARN-cluster mode Added line-break.
Can one of the admins verify this patch? |
@@ -573,10 +573,16 @@ object ApplicationMaster extends Logging { | |||
} | |||
|
|||
private[spark] def sparkContextInitialized(sc: SparkContext): Unit = { | |||
if (master == null){ |
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.
I don't think you can ever get into this situation in the real world.
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.
@vanzin We thought we can't get into this situation, but we are defending against one right now. I will remove it if you will, but I think this helps more than hurts.
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.
Yes, you could reach this, but the NPE at that point was just a side effect of a different bug. Fix that bug, NPE is gone. Remove the NPE, but leave the bug in, something else will blow up.
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.
@vanzin Okay.
…xt in YARN-cluster mode Removed checking for null in AM. Refactored configuration-check to SparkConf.
@vanzin Moved the check to |
|
||
// System property spark.yarn.app.id must be set if user code ran by AM on a YARN cluster | ||
// yarn-standalone is deprecated, but still supported | ||
if ((get("spark.master") == "yarn-cluster" || get("spark.master") == "yarn-standalone") && |
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.
if ((master == "yarn-cluster" || master == "yarn-standalone") && !_conf.contains("spark.yarn.app.id""))
I don't see any method named get
so I'm not sure your code would even compile.
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.
There are two get
s. Tested on local and remote YARN clusters.
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.
Oh my bad. I thought this was still in SparkContext. In fact, I think the check should be there. When I mentioned "check for spark.yarn.app.id
in SparkConf" I didn't mean to change SparkConf, I meant to do as I suggested above (!_conf.contains("spark.yarn.app.id"")
).
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.
What we do here is actually an act of validating the configuration. It seems to be a good place inside validateSettings
. There is no information required from outside to do this check.
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.
SparkConf
is not just for SparkContext
.
@@ -448,6 +448,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging { | |||
} | |||
} | |||
} | |||
|
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.
I can probably remove this on merge, but there's a stray blank here.
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.
As I saw, usually there is a blank line before ending of long methods and classes. You might remove it if you will.
Would anyone verify this? |
ok to test |
Merged build triggered. |
Merged build started. |
Test build #32699 has started for PR 6083 at commit |
Test build #32699 has finished for PR 6083 at commit
|
Merged build finished. Test PASSed. |
Test PASSed. |
@srowen Thanks! |
What do you guys think? Is this subject to pull? |
Only pending @andrewor14 's comment I think. If there's another change, nix that blank line. Blank lines there are fine but not worth adding in an unrelated change. |
Thanks @ehnalis merging into master 1.4. |
(also nixed the blank line) |
…xt in YARN-cluster mode Added a simple checking for SparkContext. Also added two rational checking against null at AM object. Author: ehnalis <zoltan.zvara@gmail.com> Closes #6083 from ehnalis/cluster and squashes the following commits: 926bd96 [ehnalis] Moved check to SparkContext. 7c89b6e [ehnalis] Remove false line. ea2a5fe [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 4924e01 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 39e4fa3 [ehnalis] SPARK-7504 [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 9f287c5 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode (cherry picked from commit 8e3822a) Signed-off-by: Andrew Or <andrew@databricks.com>
Thanks, I'm happy and excited that I was able to help! :-) |
…xt in YARN-cluster mode Added a simple checking for SparkContext. Also added two rational checking against null at AM object. Author: ehnalis <zoltan.zvara@gmail.com> Closes apache#6083 from ehnalis/cluster and squashes the following commits: 926bd96 [ehnalis] Moved check to SparkContext. 7c89b6e [ehnalis] Remove false line. ea2a5fe [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 4924e01 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 39e4fa3 [ehnalis] SPARK-7504 [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 9f287c5 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode
…xt in YARN-cluster mode Added a simple checking for SparkContext. Also added two rational checking against null at AM object. Author: ehnalis <zoltan.zvara@gmail.com> Closes apache#6083 from ehnalis/cluster and squashes the following commits: 926bd96 [ehnalis] Moved check to SparkContext. 7c89b6e [ehnalis] Remove false line. ea2a5fe [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 4924e01 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 39e4fa3 [ehnalis] SPARK-7504 [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 9f287c5 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode
…xt in YARN-cluster mode Added a simple checking for SparkContext. Also added two rational checking against null at AM object. Author: ehnalis <zoltan.zvara@gmail.com> Closes apache#6083 from ehnalis/cluster and squashes the following commits: 926bd96 [ehnalis] Moved check to SparkContext. 7c89b6e [ehnalis] Remove false line. ea2a5fe [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 4924e01 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 39e4fa3 [ehnalis] SPARK-7504 [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode 9f287c5 [ehnalis] [SPARK-7504] [YARN] NullPointerException when initializing SparkContext in YARN-cluster mode
Added a simple checking for SparkContext.
Also added two rational checking against null at AM object.