You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/16 11:28:19 UTC

[GitHub] [spark] yaooqinn commented on a change in pull request #31850: [SPARK-21449][SQL][FOLLOWUP] Avoid log undesirable IllegalStateException when state close

yaooqinn commented on a change in pull request #31850:
URL: https://github.com/apache/spark/pull/31850#discussion_r595081457



##########
File path: sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala
##########
@@ -155,7 +155,24 @@ private[hive] class HiveClientImpl(
     }
   }
 
-  ShutdownHookManager.addShutdownHook(() => state.close())
+  private def closeState(): Unit = {
+    // these temp files are registered in o.a.h.u.ShutdownHookManager too
+    // the state.close() will delete them if they are not null and try remove them
+    // from the o.a.h.u.ShutdownHookManager which causes IllegalStateException
+    // we delete them ahead with a high priority hook here and set them to null to
+    // bypass the deletion in state.close()
+    if (state.getTmpOutputFile != null) {
+      state.getTmpOutputFile.delete()
+      state.setTmpOutputFile(null)

Review comment:
       this bypasses the hook canceling here
   
   ```java
   // org.apache.hadoop.hive.common.FileUtils#deleteTmpFile
   
     /**
      * delete a temporary file and remove it from delete-on-exit hook.
      */
     public static boolean deleteTmpFile(File tempFile) {
       if (tempFile != null) {
         tempFile.delete();
         ShutdownHookManager.cancelDeleteOnExit(tempFile);
         return true;
       }
       return false;
     }
   ```
   for `org.apache.hadoop.hive.ql.session.SessionState#deleteTmpOutputFile` and `deleteTmpErrOutputFile`




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org