[ 
https://issues.apache.org/jira/browse/HIVE-24270?focusedWorklogId=500396&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-500396
 ]

ASF GitHub Bot logged work on HIVE-24270:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Oct/20 03:05
            Start Date: 14/Oct/20 03:05
    Worklog Time Spent: 10m 
      Work Description: rbalamohan commented on a change in pull request #1577:
URL: https://github.com/apache/hive/pull/1577#discussion_r504372394



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/session/SessionState.java
##########
@@ -1852,6 +1863,9 @@ public void close() throws IOException {
       closeSparkSession();
       registry.closeCUDFLoaders();
       dropSessionPaths(sessionConf);
+      if (pathCleaner != null) {
+        pathCleaner.shutdown();

Review comment:
       dropSessionPaths() would have created the thread and would have started 
deleting. As shutdown() is called immediately, it would stop further processing 
and quit without purging other entries. (i.e This would prevent the thread from 
processing > 1024 entries in PathCleaner. It would be good to wait until all 
files are purged before quitting the thread.

##########
File path: ql/src/java/org/apache/hadoop/hive/ql/PathCleaner.java
##########
@@ -0,0 +1,130 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.hive.ql;
+
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.concurrent.BlockingDeque;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * This class is used to asynchronously remove directories after query 
execution
+ */
+public class PathCleaner {
+
+  private static final Logger LOG = 
LoggerFactory.getLogger(PathCleaner.class.getName());
+
+  private final BlockingDeque<AsyncDeleteAction> deleteActions = new 
LinkedBlockingDeque<>();
+  private final AtomicBoolean isShutdown = new AtomicBoolean();
+  private final Thread cleanupThread;
+
+  public PathCleaner(String name) {
+    cleanupThread = new Thread(new Runnable() {
+      @Override
+      public void run() {
+        while (!isShutdown.get()) {
+          Path path = null;
+          FileSystem fs;
+          try {
+            AsyncDeleteAction firstAction = deleteActions.poll(30, 
TimeUnit.SECONDS);
+            if (firstAction != null) {

Review comment:
       Refer to the other comment plz. If firstAction is null, shutdown 
condition can be checked to quit the thread.




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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 500396)
    Time Spent: 20m  (was: 10m)

> Move scratchdir cleanup to background
> -------------------------------------
>
>                 Key: HIVE-24270
>                 URL: https://issues.apache.org/jira/browse/HIVE-24270
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Mustafa Iman
>            Assignee: Mustafa Iman
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> In cloud environment, scratchdir cleaning at the end of the query may take 
> long time. This causes client to hang up to 1 minute even after the results 
> were streamed back. During this time client just waits for cleanup to finish. 
> Cleanup can take place in the background in HiveServer.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to