sumeetgajjar opened a new pull request #33770:
URL: https://github.com/apache/spark/pull/33770


   This PR backports #32043 to branch-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'.
     8. If you want to add or modify an error type or message, please read the 
guideline first in
        'core/src/main/resources/error/README.md'.
   -->
   
   ### 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 PR prevents reregistering BlockManager when a Executor is shutting 
down. It is achieved by checking  `executorShutdown` before calling 
`env.blockManager.reregister()`. 
   
   ### 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 change is required since Spark reports executors as active, even they 
are removed.
   I was testing Dynamic Allocation on K8s with about 300 executors. While 
doing so, when the executors were torn down due to 
`spark.dynamicAllocation.executorIdleTimeout`, I noticed all the executor pods 
being removed from K8s, however, under the "Executors" tab in SparkUI, I could 
see some executors listed as alive.  
[spark.sparkContext.statusTracker.getExecutorInfos.length](https://github.com/apache/spark/blob/65da9287bc5112564836a555cd2967fc6b05856f/core/src/main/scala/org/apache/spark/SparkStatusTracker.scala#L105)
 also returned a value greater than 1. 
   
   
   ### 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.
   -->
   Added a new test.
   
   ## Logs
   Following are the logs of the executor(Id:303) which re-registers 
`BlockManager`
   ```
   21/04/02 21:33:28 INFO CoarseGrainedExecutorBackend: Got assigned task 1076
   21/04/02 21:33:28 INFO Executor: Running task 4.0 in stage 3.0 (TID 1076)
   21/04/02 21:33:28 INFO MapOutputTrackerWorker: Updating epoch to 302 and 
clearing cache
   21/04/02 21:33:28 INFO TorrentBroadcast: Started reading broadcast variable 3
   21/04/02 21:33:28 INFO TransportClientFactory: Successfully created 
connection to /100.100.195.227:33703 after 76 ms (62 ms spent in bootstraps)
   21/04/02 21:33:28 INFO MemoryStore: Block broadcast_3_piece0 stored as bytes 
in memory (estimated size 2.4 KB, free 168.0 MB)
   21/04/02 21:33:28 INFO TorrentBroadcast: Reading broadcast variable 3 took 
168 ms
   21/04/02 21:33:28 INFO MemoryStore: Block broadcast_3 stored as values in 
memory (estimated size 3.9 KB, free 168.0 MB)
   21/04/02 21:33:29 INFO MapOutputTrackerWorker: Don't have map outputs for 
shuffle 1, fetching them
   21/04/02 21:33:29 INFO MapOutputTrackerWorker: Doing the fetch; tracker 
endpoint = 
NettyRpcEndpointRef(spark://mapoutputtrac...@da-lite-test-4-7a57e478947d206d-driver-svc.dex-app-n5ttnbmg.svc:7078)
   21/04/02 21:33:29 INFO MapOutputTrackerWorker: Got the output locations
   21/04/02 21:33:29 INFO ShuffleBlockFetcherIterator: Getting 2 non-empty 
blocks including 1 local blocks and 1 remote blocks
   21/04/02 21:33:30 INFO TransportClientFactory: Successfully created 
connection to /100.100.80.103:40971 after 660 ms (528 ms spent in bootstraps)
   21/04/02 21:33:30 INFO ShuffleBlockFetcherIterator: Started 1 remote fetches 
in 1042 ms
   21/04/02 21:33:31 INFO Executor: Finished task 4.0 in stage 3.0 (TID 1076). 
1276 bytes result sent to driver
   .
   . 
   .
   21/04/02 21:34:16 INFO CoarseGrainedExecutorBackend: Driver commanded a 
shutdown
   21/04/02 21:34:16 INFO Executor: Told to re-register on heartbeat
   21/04/02 21:34:16 INFO BlockManager: BlockManager BlockManagerId(303, 
100.100.122.34, 41265, None) re-registering with master
   21/04/02 21:34:16 INFO BlockManagerMaster: Registering BlockManager 
BlockManagerId(303, 100.100.122.34, 41265, None)
   21/04/02 21:34:16 INFO BlockManagerMaster: Registered BlockManager 
BlockManagerId(303, 100.100.122.34, 41265, None)
   21/04/02 21:34:16 INFO BlockManager: Reporting 0 blocks to the master.
   21/04/02 21:34:16 INFO MemoryStore: MemoryStore cleared
   21/04/02 21:34:16 INFO BlockManager: BlockManager stopped
   21/04/02 21:34:16 INFO FileDataSink: Closing sink with output file = 
/tmp/safari-events/.des_analysis/safari-events/hdp_spark_monitoring_random-container-037caf27-6c77-433f-820f-03cd9c7d9b6e-spark-8a492407d60b401bbf4309a14ea02ca2_events.tsv
   21/04/02 21:34:16 INFO HonestProfilerBasedThreadSnapshotProvider: Stopping 
agent
   21/04/02 21:34:16 INFO HonestProfilerHandler: Stopping honest profiler agent
   21/04/02 21:34:17 INFO ShutdownHookManager: Shutdown hook called
   21/04/02 21:34:17 INFO ShutdownHookManager: Deleting directory 
/var/data/spark-d886588c-2a7e-491d-bbcb-4f58b3e31001/spark-4aa337a0-60c0-45da-9562-8c50eaff3cea
   
   ```


-- 
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]

Reply via email to