sthandassery opened a new pull request, #60589: URL: https://github.com/apache/spark/pull/60589
### What changes were proposed in this pull request? `TaskSchedulerImpl` now creates its `HealthTracker` in `initialize(backend)`, using that backend as the `ExecutorAllocationClient`. Previously it used a `lazy val` that read `sc.schedulerBackend`. ### Why are the changes needed? `CoarseGrainedSchedulerBackend` creates its driver endpoint in its constructor, and the endpoint starts sending `ReviveOffers` immediately. `SparkContext` only assigns `_schedulerBackend` after `createTaskScheduler` returns. If the first `resourceOffers` call wins that race, the lazy `healthTrackerOpt` is created without an allocation client and stays that way for the whole application. As a result: - `spark.excludeOnFailure.killExcludedExecutors` does nothing: `Not attempting to kill excluded executor id 0 since allocation client is not defined.` - executors on an excluded node are not killed - when a task set becomes unschedulable, the idle excluded executor is not killed, so the stage waits and then aborts The `lazy val` was added by SPARK-20898 to fix this same symptom. It only works when the tracker is first accessed after `SparkContext` assigns the backend. Whether that holds depends on timing: on `local-cluster` with FAIR scheduling and an allocation file, the tracker had no allocation client in all 3 runs; with FIFO, in none of 5. Reading `this.backend` from the `lazy val` would not be enough, because the offer can arrive before `initialize()` is called. With this change, an early offer just sees no tracker. That's fine, because no executors have registered yet. ### Does this PR introduce _any_ user-facing change? Yes. - When exclusion is enabled, the kill paths above now work no matter how startup is timed. - An invalid exclusion config (e.g. `spark.excludeOnFailure.task.maxTaskAttemptsPerExecutor=0`) now fails SparkContext creation with the validation error. Before, the context started, the driver endpoint kept logging `Ignoring error`, and the first job shut down the SparkContext. ### How was this patch tested? New test in `TaskSchedulerImplSuite`: the tracker uses the backend passed to `initialize()` as its allocation client, even when an offer arrives first. It fails without this change. Ran all core scheduler suites (`org.apache.spark.scheduler.*`) and `SparkContextSchedulerCreationSuite`, plus `YarnSchedulerBackendSuite` and `KubernetesClusterManagerSuite`. Manually on `local-cluster[2,1,1024]` with `spark.excludeOnFailure.enabled=true` and `spark.excludeOnFailure.killExcludedExecutors=true`, running a job where one task fails once: | Setup | Before | After | |---|---|---| | FIFO | `Killing excluded executor id 0 ...` | same | | FAIR + `spark.scheduler.allocation.file` | `Not attempting to kill excluded executor id 0 since allocation client is not defined.` | `Killing excluded executor id 1 ...` | Checking the tracker's allocation client directly: FAIR with an allocation file was `None` in 3/3 runs before the change and the backend in 3/3 runs after. FIFO had the backend in every run, both before and after. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
