You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ji...@apache.org on 2026/04/30 19:53:47 UTC
(spark) branch master updated: [SPARK-56575][CORE] Extract scheduleResubmit() helper to remove identical code blocks
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push:
new c9e2d65176e4 [SPARK-56575][CORE] Extract scheduleResubmit() helper to remove identical code blocks
c9e2d65176e4 is described below
commit c9e2d65176e4ce4045d7ca80d971ab6d02c5a9f4
Author: Xingbo Jiang <xi...@databricks.com>
AuthorDate: Thu Apr 30 12:53:37 2026 -0700
[SPARK-56575][CORE] Extract scheduleResubmit() helper to remove identical code blocks
### What changes were proposed in this pull request?
Extract a `scheduleResubmit()` helper method in `DAGScheduler` to replace three identical code blocks that schedule `ResubmitFailedStages` via `messageScheduler`.
### Why are the changes needed?
The same 5-line block for scheduling a `ResubmitFailedStages` event is duplicated in three places (rollback handling, fetch failure handling, and barrier stage failure handling). Extracting it into a helper reduces duplication and improves readability.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
This is a pure refactoring with no behavior change. Existing tests cover the affected code paths.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.6)
Closes #55614 from jiangxb1987/SPARK-56575.
Authored-by: Xingbo Jiang <xi...@databricks.com>
Signed-off-by: Xingbo Jiang <xi...@databricks.com>
---
.../org/apache/spark/scheduler/DAGScheduler.scala | 30 ++++++++++------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala b/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
index f3958bfddec9..22720b98aafd 100644
--- a/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
+++ b/core/src/main/scala/org/apache/spark/scheduler/DAGScheduler.scala
@@ -325,6 +325,16 @@ private[spark] class DAGScheduler(
private val messageScheduler =
ThreadUtils.newDaemonSingleThreadScheduledExecutor("dag-scheduler-message")
+ private def scheduleResubmit(): Unit = {
+ messageScheduler.schedule(
+ new Runnable {
+ override def run(): Unit = eventProcessLoop.post(ResubmitFailedStages)
+ },
+ DAGScheduler.RESUBMIT_TIMEOUT,
+ TimeUnit.MILLISECONDS
+ )
+ }
+
private[spark] var eventProcessLoop = new DAGSchedulerEventProcessLoop(this)
// Used for test only. Some tests uses the same thread of the event poster to
// process the events to ensure the deterministic behavior during the test.
@@ -2179,13 +2189,7 @@ private[spark] class DAGScheduler(
if (noResubmitEnqueued) {
logInfo(log"Resubmitting ${MDC(FAILED_STAGE, stage)} " +
log"(${MDC(FAILED_STAGE_NAME, stage.name)}) due to rollback.")
- messageScheduler.schedule(
- new Runnable {
- override def run(): Unit = eventProcessLoop.post(ResubmitFailedStages)
- },
- DAGScheduler.RESUBMIT_TIMEOUT,
- TimeUnit.MILLISECONDS
- )
+ scheduleResubmit()
}
}
@@ -2510,13 +2514,7 @@ private[spark] class DAGScheduler(
log"Resubmitting ${MDC(STAGE, mapStage)} " +
log"(${MDC(STAGE_NAME, mapStage.name)}) and ${MDC(FAILED_STAGE, failedStage)} " +
log"(${MDC(FAILED_STAGE_NAME, failedStage.name)}) due to fetch failure")
- messageScheduler.schedule(
- new Runnable {
- override def run(): Unit = eventProcessLoop.post(ResubmitFailedStages)
- },
- DAGScheduler.RESUBMIT_TIMEOUT,
- TimeUnit.MILLISECONDS
- )
+ scheduleResubmit()
}
}
@@ -2623,9 +2621,7 @@ private[spark] class DAGScheduler(
if (noResubmitEnqueued) {
logInfo(log"Resubmitting ${MDC(FAILED_STAGE, failedStage)} " +
log"(${MDC(FAILED_STAGE_NAME, failedStage.name)}) due to barrier stage failure.")
- messageScheduler.schedule(new Runnable {
- override def run(): Unit = eventProcessLoop.post(ResubmitFailedStages)
- }, DAGScheduler.RESUBMIT_TIMEOUT, TimeUnit.MILLISECONDS)
+ scheduleResubmit()
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org