Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -563,17 +563,14 @@ private[spark] class ExecutorMonitor(
def updateTimeout(): Unit = {
val oldDeadline = timeoutAt
val newDeadline = if (idleStart >= 0) {
val timeout = if (cachedBlocks.nonEmpty || (shuffleIds != null && shuffleIds.nonEmpty)) {
val _cacheTimeout = if (cachedBlocks.nonEmpty) storageTimeoutNs else Long.MaxValue
val _shuffleTimeout = if (shuffleIds != null && shuffleIds.nonEmpty) {
shuffleTimeoutNs
} else {
Long.MaxValue
}
math.min(_cacheTimeout, _shuffleTimeout)
val _cacheTimeout = if (cachedBlocks.nonEmpty) storageTimeoutNs else 0
val _shuffleTimeout = if (shuffleIds != null && shuffleIds.nonEmpty) {
shuffleTimeoutNs
} else {
idleTimeoutNs
0
}
// timeout should be max of idleTimeout, storageTimeout and shuffleTimeout
val timeout = Seq(_cacheTimeout, _shuffleTimeout, idleTimeoutNs).max
val deadline = idleStart + timeout
if (deadline >= 0) deadline else Long.MaxValue
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,34 @@ class ExecutorMonitorSuite extends SparkFunSuite {
assert(monitor.executorCount == 0 )
}

for (isShuffleTrackingEnabled <- Seq(true, false)) {
test(s"SPARK-43398: executor timeout should be max of shuffle and rdd timeout with" +
s" shuffleTrackingEnabled as $isShuffleTrackingEnabled") {
conf
.set(DYN_ALLOCATION_SHUFFLE_TRACKING_TIMEOUT.key, "240s")
.set(DYN_ALLOCATION_SHUFFLE_TRACKING_ENABLED, isShuffleTrackingEnabled)
.set(SHUFFLE_SERVICE_ENABLED, false)
monitor = new ExecutorMonitor(conf, client, null, clock, allocationManagerSource())

monitor.onExecutorAdded(SparkListenerExecutorAdded(clock.getTimeMillis(), "1", execInfo))
knownExecs += "1"
val stage1 = stageInfo(1, shuffleId = 0)
monitor.onJobStart(SparkListenerJobStart(1, clock.getTimeMillis(), Seq(stage1)))
monitor.onBlockUpdated(rddUpdate(1, 0, "1"))
val t1 = taskInfo("1", 1)
monitor.onTaskStart(SparkListenerTaskStart(1, 1, t1))
monitor.onTaskEnd(SparkListenerTaskEnd(1, 1, "foo", Success, t1, new ExecutorMetrics, null))
monitor.onJobEnd(SparkListenerJobEnd(1, clock.getTimeMillis(), JobSucceeded))

if (isShuffleTrackingEnabled) {
assert(monitor.timedOutExecutors(storageDeadline).isEmpty)
assert(monitor.timedOutExecutors(shuffleDeadline) == Seq("1"))
} else {
assert(monitor.timedOutExecutors(idleDeadline).isEmpty)
assert(monitor.timedOutExecutors(storageDeadline) == Seq("1"))
}
}
}

private def idleDeadline: Long = clock.nanoTime() + idleTimeoutNs + 1
private def storageDeadline: Long = clock.nanoTime() + storageTimeoutNs + 1
Expand Down