Skip to content
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

[SPARK-35011][CORE][3.0] Avoid Block Manager registrations when StopExecutor msg is in-flight #33782

Closed

Conversation

sumeetgajjar
Copy link
Contributor

This PR backports #32114 to 3.0


What changes were proposed in this pull request?

This patch proposes a fix to prevent triggering BlockManager reregistration while StopExecutor msg is in-flight.
Here on receiving StopExecutor msg, we do not remove the corresponding BlockManagerInfo from blockManagerInfo map, instead we mark it as dead by updating the corresponding executorRemovalTs. There's a separate cleanup thread running to periodically remove the stale BlockManagerInfo from blockManangerInfo map.

Now if a recently removed BlockManager tries to register, the driver simply ignores it since the blockManagerInfo map already contains an entry for it. The same applies to BlockManagerHeartbeat, if the BlockManager belongs to a recently removed executor, the blockManagerInfo map would contain an entry and we shall not ask the corresponding BlockManager to re-register.

Why are the changes needed?

This changes are needed since BlockManager reregistration while executor is shutting down causes inconsistent bookkeeping of executors in Spark.
Consider the following scenario:

  • CoarseGrainedSchedulerBackend issues async StopExecutor on executorEndpoint
  • CoarseGrainedSchedulerBackend removes that executor from Driver's internal data structures and publishes SparkListenerExecutorRemoved on the listenerBus.
  • Executor has still not processed StopExecutor from the Driver
  • Driver receives heartbeat from the Executor, since it cannot find the executorId in its data structures, it responds with HeartbeatResponse(reregisterBlockManager = true)
  • BlockManager on the Executor reregisters with the BlockManagerMaster and SparkListenerBlockManagerAdded is published on the listenerBus
  • Executor starts processing the StopExecutor and exits
  • AppStatusListener picks the SparkListenerBlockManagerAdded event and updates AppStatusStore
  • statusTracker.getExecutorInfos refers AppStatusStore to get the list of executors which returns the dead executor as alive.

Does this PR introduce any user-facing change?

No

How was this patch tested?

  • Modified the existing unittests.
  • Ran a simple test application on minikube that asserts on number of executors are zero once the executor idle timeout is reached.

@sumeetgajjar
Copy link
Contributor Author

@dongjoon-hyun @mridulm @Ngone51
Could you please take a look at this backport PR?

…or msg is in-flight

This patch proposes a fix to prevent triggering BlockManager reregistration while `StopExecutor` msg is in-flight.
Here on receiving `StopExecutor` msg, we do not remove the corresponding `BlockManagerInfo` from `blockManagerInfo` map, instead we mark it as dead by updating the corresponding `executorRemovalTs`. There's a separate cleanup thread running to periodically remove the stale `BlockManagerInfo` from `blockManangerInfo` map.

Now if a recently removed `BlockManager` tries to register, the driver simply ignores it since the `blockManagerInfo` map already contains an entry for it. The same applies to `BlockManagerHeartbeat`, if the BlockManager belongs to a recently removed executor, the `blockManagerInfo` map would contain an entry and we shall not ask the corresponding `BlockManager` to re-register.

This changes are needed since BlockManager reregistration while executor is shutting down causes inconsistent bookkeeping of executors in Spark.
Consider the following scenario:
- `CoarseGrainedSchedulerBackend` issues async `StopExecutor` on executorEndpoint
- `CoarseGrainedSchedulerBackend` removes that executor from Driver's internal data structures and publishes `SparkListenerExecutorRemoved` on the `listenerBus`.
- Executor has still not processed `StopExecutor` from the Driver
- Driver receives heartbeat from the Executor, since it cannot find the `executorId` in its data structures, it responds with `HeartbeatResponse(reregisterBlockManager = true)`
- `BlockManager` on the Executor reregisters with the `BlockManagerMaster` and `SparkListenerBlockManagerAdded` is published on the `listenerBus`
- Executor starts processing the `StopExecutor` and exits
- `AppStatusListener` picks the `SparkListenerBlockManagerAdded` event and updates `AppStatusStore`
- `statusTracker.getExecutorInfos` refers `AppStatusStore` to get the list of executors which returns the dead executor as alive.

No

- Modified the existing unittests.
- Ran a simple test application on minikube that asserts on number of executors are zero once the executor idle timeout is reached.

Closes apache#32114 from sumeetgajjar/SPARK-35011.

Authored-by: Sumeet Gajjar <sumeetgajjar93@gmail.com>
Signed-off-by: yi.wu <yi.wu@databricks.com>
@AmplabJenkins
Copy link

Can one of the admins verify this patch?

@sumeetgajjar
Copy link
Contributor Author

sumeetgajjar commented Aug 19, 2021

Github check failed due to a unrelated UT failure.

info] - multiple joins *** FAILED *** (1 second, 104 milliseconds)
[info]   ArrayBuffer(BroadcastHashJoin [b#147460], [a#147469], Inner, BuildLeft

I do not have permission to re-reun the checks, could someone please re-run them?

Edit: I ran the same UT locally, it passed without any issues. :)

@Ngone51
Copy link
Member

Ngone51 commented Aug 19, 2021

@sumeetgajjar I retriggered the test. You can also retrigger the test by close and reopen the PR.

@sumeetgajjar sumeetgajjar reopened this Aug 19, 2021
Ngone51 pushed a commit that referenced this pull request Aug 20, 2021
…xecutor msg is in-flight

This PR backports #32114 to 3.0
<hr>

<!--
Thanks for sending a pull request!  Here are some tips for you:
  1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
  2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
  3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
  4. Be sure to keep the PR description updated to reflect all changes.
  5. Please write your PR title to summarize what this PR proposes.
  6. If possible, provide a concise example to reproduce the issue for a faster review.
  7. If you want to add a new configuration, please read the guideline first for naming configurations in
     'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
-->

### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
  1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
  2. If you fix some SQL features, you can provide some references of other DBMSes.
  3. If there is design documentation, please add the link.
  4. If there is a discussion in the mailing list, please add the link.
-->
This patch proposes a fix to prevent triggering BlockManager reregistration while `StopExecutor` msg is in-flight.
Here on receiving `StopExecutor` msg, we do not remove the corresponding `BlockManagerInfo` from `blockManagerInfo` map, instead we mark it as dead by updating the corresponding `executorRemovalTs`. There's a separate cleanup thread running to periodically remove the stale `BlockManagerInfo` from `blockManangerInfo` map.

Now if a recently removed `BlockManager` tries to register, the driver simply ignores it since the `blockManagerInfo` map already contains an entry for it. The same applies to `BlockManagerHeartbeat`, if the BlockManager belongs to a recently removed executor, the `blockManagerInfo` map would contain an entry and we shall not ask the corresponding `BlockManager` to re-register.

### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
  1. If you propose a new API, clarify the use case for a new API.
  2. If you fix a bug, you can clarify why it is a bug.
-->
This changes are needed since BlockManager reregistration while executor is shutting down causes inconsistent bookkeeping of executors in Spark.
Consider the following scenario:
- `CoarseGrainedSchedulerBackend` issues async `StopExecutor` on executorEndpoint
- `CoarseGrainedSchedulerBackend` removes that executor from Driver's internal data structures and publishes `SparkListenerExecutorRemoved` on the `listenerBus`.
- Executor has still not processed `StopExecutor` from the Driver
- Driver receives heartbeat from the Executor, since it cannot find the `executorId` in its data structures, it responds with `HeartbeatResponse(reregisterBlockManager = true)`
- `BlockManager` on the Executor reregisters with the `BlockManagerMaster` and `SparkListenerBlockManagerAdded` is published on the `listenerBus`
- Executor starts processing the `StopExecutor` and exits
- `AppStatusListener` picks the `SparkListenerBlockManagerAdded` event and updates `AppStatusStore`
- `statusTracker.getExecutorInfos` refers `AppStatusStore` to get the list of executors which returns the dead executor as alive.

### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No

### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->

- Modified the existing unittests.
- Ran a simple test application on minikube that asserts on number of executors are zero once the executor idle timeout is reached.

Closes #33782 from sumeetgajjar/SPARK-35011-br-3.0.

Authored-by: Sumeet Gajjar <sumeetgajjar93@gmail.com>
Signed-off-by: yi.wu <yi.wu@databricks.com>
@Ngone51
Copy link
Member

Ngone51 commented Aug 20, 2021

GA passed. Merged to branch-3.0, thanks!

@Ngone51 Ngone51 closed this Aug 20, 2021
@sumeetgajjar
Copy link
Contributor Author

Thank you @Ngone51 for merging this.

dongjoon-hyun pushed a commit that referenced this pull request Sep 10, 2021
…en StopExecutor msg is in-flight"

This reverts commit 0a31f1f.

### What changes were proposed in this pull request?

Revert #33782

### Why are the changes needed?

It breaks the expected `BlockManager` re-registration (e.g., heartbeat loss of an active executor) due to deferred removal of `BlockManager`, see the check:
https://github.com/apache/spark/blob/9cefde8db373a3433b7e3ce328e4a2ce83b1aca2/core/src/main/scala/org/apache/spark/storage/BlockManagerMasterEndpoint.scala#L551

### Does this PR introduce _any_ user-facing change?

No

### How was this patch tested?

Pass existing tests.

Closes #33961 from Ngone51/revert-35011-3.0.

Authored-by: yi.wu <yi.wu@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants