wankunde commented on pull request #28850:
URL: https://github.com/apache/spark/pull/28850#issuecomment-648673248


   > @wankunde Do you have a way to reproduce the OOM?
   
   Just setup and stop a few new SparkSessions, and use spark-sql to read 
tables managed by hive.
   
   HiveCatalog will init a new child thread in 
`org.apache.hive.common.util.ShutdownHookManager`, which will have a reference 
to `SparkContext`(because SparkContext is a inheritable thread local variable)
   
   ```java
   Runtime.getRuntime().addShutdownHook(
         new Thread() {
           @Override
           public void run() {
             MGR.shutdownInProgress.set(true);
             for (Runnable hook : getShutdownHooksInOrder()) {
               try {
                 hook.run();
               } catch (Throwable ex) {
                 LOG.warn("ShutdownHook '" + hook.getClass().getSimpleName() +
                          "' failed, " + ex.toString(), ex);
               }
             }
           }
         }
       );
   ```
   
   Those sparkContexts cannot be garbage collected after stopped because there 
are references from java.lang.ApplicationShutdownHooks to those sparkContexts..


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

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