Skip to content

Commit 586feb5

Browse files
aarondavpwendell
authored andcommitted
[SPARK-2350] Don't NPE while launching drivers
Prior to this change, we could throw a NPE if we launch a driver while another one is waiting, because removing from an iterator while iterating over it is not safe. Author: Aaron Davidson <[email protected]> Closes apache#1289 from aarondav/master-fail and squashes the following commits: 1cf1cf4 [Aaron Davidson] SPARK-2350: Don't NPE while launching drivers
1 parent 5fa0a05 commit 586feb5

File tree

1 file changed

+1
-1
lines changed
  • core/src/main/scala/org/apache/spark/deploy/master

1 file changed

+1
-1
lines changed

core/src/main/scala/org/apache/spark/deploy/master/Master.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ private[spark] class Master(
481481
// First schedule drivers, they take strict precedence over applications
482482
val shuffledWorkers = Random.shuffle(workers) // Randomization helps balance drivers
483483
for (worker <- shuffledWorkers if worker.state == WorkerState.ALIVE) {
484-
for (driver <- waitingDrivers) {
484+
for (driver <- List(waitingDrivers: _*)) { // iterate over a copy of waitingDrivers
485485
if (worker.memoryFree >= driver.desc.mem && worker.coresFree >= driver.desc.cores) {
486486
launchDriver(worker, driver)
487487
waitingDrivers -= driver

0 commit comments

Comments
 (0)