-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-21383][Core] Fix the YarnAllocator allocates more Resource #18651
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 1 commit
818c912
aba617e
0980a6a
856ebd6
bf7f78c
cc73e5b
582f424
7703494
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 |
|---|---|---|
|
|
@@ -82,6 +82,8 @@ private[yarn] class YarnAllocator( | |
|
|
||
| @volatile private var numExecutorsRunning = 0 | ||
|
|
||
| @volatile private var numExecutorToBeLaunched = 0 | ||
|
|
||
| /** | ||
| * Used to generate a unique ID per executor | ||
| * | ||
|
|
@@ -294,7 +296,8 @@ private[yarn] class YarnAllocator( | |
| def updateResourceRequests(): Unit = { | ||
| val pendingAllocate = getPendingAllocate | ||
| val numPendingAllocate = pendingAllocate.size | ||
| val missing = targetNumExecutors - numPendingAllocate - numExecutorsRunning | ||
| val missing = targetNumExecutors - numPendingAllocate - | ||
| numExecutorToBeLaunched - numExecutorsRunning | ||
|
|
||
|
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. can you also add in a debug message here, something like below. I found this very useful when debugging this issue and think it would be useful for debugging other allocating issues in the future. logDebug(s"Updating resource requests, target: $targetNumExecutors, pending: " +
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. Thanks for your advice! I just add the debug info. |
||
| if (missing > 0) { | ||
| logInfo(s"Will request $missing executor container(s), each with " + | ||
|
|
@@ -505,32 +508,37 @@ private[yarn] class YarnAllocator( | |
|
|
||
| if (numExecutorsRunning < targetNumExecutors) { | ||
| if (launchContainers) { | ||
| launcherPool.execute(new Runnable { | ||
| override def run(): Unit = { | ||
| try { | ||
| new ExecutorRunnable( | ||
| Some(container), | ||
| conf, | ||
| sparkConf, | ||
| driverUrl, | ||
| executorId, | ||
| executorHostname, | ||
| executorMemory, | ||
| executorCores, | ||
| appAttemptId.getApplicationId.toString, | ||
| securityMgr, | ||
| localResources | ||
| ).run() | ||
| updateInternalState() | ||
| } catch { | ||
| case NonFatal(e) => | ||
| logError(s"Failed to launch executor $executorId on container $containerId", e) | ||
| // Assigned container should be released immediately to avoid unnecessary resource | ||
| // occupation. | ||
| amClient.releaseAssignedContainer(containerId) | ||
| try { | ||
| numExecutorToBeLaunched += 1 | ||
|
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. This is not thread safe. |
||
| launcherPool.execute(new Runnable { | ||
| override def run(): Unit = { | ||
| try { | ||
| new ExecutorRunnable( | ||
| Some(container), | ||
| conf, | ||
| sparkConf, | ||
| driverUrl, | ||
| executorId, | ||
| executorHostname, | ||
| executorMemory, | ||
| executorCores, | ||
| appAttemptId.getApplicationId.toString, | ||
| securityMgr, | ||
| localResources | ||
| ).run() | ||
| updateInternalState() | ||
| } catch { | ||
| case NonFatal(e) => | ||
| logError(s"Failed to launch executor $executorId on container $containerId", e) | ||
| // Assigned container should be released immediately | ||
| // to avoid unnecessary resource occupation. | ||
| amClient.releaseAssignedContainer(containerId) | ||
| } | ||
| } | ||
| } | ||
| }) | ||
| }) | ||
| } finally { | ||
| numExecutorToBeLaunched -= 1 | ||
|
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. Same here.
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. Also, shouldn't this be done in the actual thread that launching the executor? Otherwise you're decrementing the counter as soon as the task is submitted for execution, but you're not really waiting for the task to execute.
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. Yes, you're right. When I test the code by experiment, i decrease the I will fix this soon. |
||
| } | ||
| } else { | ||
| // For test only | ||
| updateInternalState() | ||
|
|
||
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.
A better name would be
numExecutorsStarting.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.
OK,I will change the name.