Github user liyichao commented on the issue: https://github.com/apache/spark/pull/18084 Hi, I've thought more thoroughly about this. The main state involved here is Master.workers, Master.idToWorker, and WorkerInfo.drivers. Say `driverId1` runs on Worker A. Assume A is network partitioned, master calls removeWorker which set the worker's state to DEAD, and remove the worker from persistenceEngine, but does not remove it from Master.workers. Then launch the driver on Worker B. When A reconnects, it will reregister to master, then master will remove the old WorkerInfo (whose `drivers` field is not empty), and add a new WorkerInfo (say `wf_A`), whose drivers are empty. After registered, the worker then re-sync state with master by sending `WorkerLatestState` with a `driverId1`, the master does not find it in `wf_A.drivers`, so it asks worker A to kill it. After killed the driver, worker A sends `DriverStateChanged(driverId1, DriverState.KILLED)`, the master then mistakenly removes `driverId1`, which now runs on worker B. How to recognize the `DriverStateChanged` come from worker A, not worker B? Maybe we can add a field `workerId` to `DriverStateChanged`, but is it possible the second run of `driverId1` is on worker A? consider the following scenario: 1. worker A network partitioned 2. master put `driverId1` to waitingDrivers 3. worker A reconnects and register 4. master launch `driverId1` on worker A 5. worker A's `WorkerLatestState(_,_,Seq(driverId1))` arrives at master Now, how does worker A handle the `LaunchDriver(driverId1)` when it has already running a driver with `driverId1`? how does the master process `WorkerLatestState`? With the above message order, master will send `KillDriver` to worker A, then worker will kill `driverId1`, which is the relaunched one, then send `DriverStateChanged` to master, master will relaunch it... After all this, I think it better to relaunch the driver with a new id to make it simple. As to the cost, `removeDriver` will be called anyway, if not here, it will be called when `DriverStateChanged` come. `persistenceEngine` have to be called because the persistent state `driver.id` changed. So the cost is justified. And `relaunchDriver` is called when worker down or master down, it seems rarely because framework code is more stable than application code, so software bugs are less likely.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org