-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-58322][CORE] Verify executor app ID matches driver at config fetch #57525
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
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -455,6 +455,7 @@ private[spark] object CoarseGrainedExecutorBackend extends Logging { | |
| } | ||
|
|
||
| val cfg = driver.askSync[SparkAppConfig](RetrieveSparkAppConfig(arguments.resourceProfileId)) | ||
| verifyAppId(cfg.sparkProperties, arguments.appId) | ||
| val props = cfg.sparkProperties ++ Seq[(String, String)](("spark.app.id", arguments.appId)) | ||
| fetcher.shutdown() | ||
|
|
||
|
|
@@ -608,4 +609,23 @@ private[spark] object CoarseGrainedExecutorBackend extends Logging { | |
| // scalastyle:on println | ||
| System.exit(1) | ||
| } | ||
|
|
||
| /** | ||
| * Verify that the executor's app ID (from the --app-id launch argument) matches the driver's | ||
| * app ID (from spark.app.id in the driver's SparkConf). A mismatch indicates the executor has | ||
| * connected to the wrong driver, likely due to driver port reuse after the original driver | ||
| * released its RPC port (e.g. via SparkContext.stop() following a fatal error) while the | ||
| * driver process remained in a zombie state. Throw SparkException to prevent the executor | ||
| * from registering to the wrong application and corrupting data. | ||
| */ | ||
| private[spark] def verifyAppId( | ||
| sparkProperties: Seq[(String, String)], | ||
| executorAppId: String): Unit = { | ||
| sparkProperties.find(_._1 == "spark.app.id").map(_._2).foreach { driverAppId => | ||
|
Member
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. [P1] Do not accept an application ID missing from the driver's cached configuration
|
||
| if (driverAppId != executorAppId) { | ||
| throw new SparkException(s"Executor app ID $executorAppId does not match driver app ID " + | ||
| s"$driverAppId. This likely means the executor connected to the wrong driver. Exiting.") | ||
| } | ||
| } | ||
| } | ||
| } | ||
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.
[P1] Validate the application ID on the registration connection
This checks the driver identity only on
driverPropsFetcher, but that RPC environment is shut down immediately afterwards. The executor subsequently creates a newSparkEnv, resolvesdriverUrlagain inCoarseGrainedExecutorBackend.onStart, and sendsRegisterExecutoron a different connection.RegisterExecutorcontains no application ID, andDriverEndpointaccepts an otherwise valid, previously unused executor ID. Consequently, if the verified driver releases its port and a different application's driver binds the same address between config retrieval and registration, the executor still registers with the wrong application despite this check. This reproduces the port-reuse/data-corruption scenario the PR is intended to prevent under the default RPC authentication settings; the Kubernetes backend has the same two-connection sequence. Please include the executor's application ID inRegisterExecutorand validate it inDriverEndpoint, or otherwise bind the identity check to the connection used for registration. Add a regression test that swaps the driver between config retrieval and registration.