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

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

                Author: ASF GitHub Bot
            Created on: 25/Apr/22 11:29
            Start Date: 25/Apr/22 11:29
    Worklog Time Spent: 10m 
      Work Description: deniskuzZ commented on code in PR #3220:
URL: https://github.com/apache/hive/pull/3220#discussion_r857525828


##########
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java:
##########
@@ -1534,43 +1538,50 @@ public void dropDatabase(String catalogName, String 
dbName, boolean deleteData,
    * @param maxBatchSize
    * @throws TException
    */
-  private void dropDatabaseCascadePerTable(String catName, String dbName, 
List<String> tableList,
-                                           boolean deleteData, int 
maxBatchSize) throws TException {
-    String dbNameWithCatalog = prependCatalogToDbName(catName, dbName, conf);
-    for (Table table : new TableIterable(this, catName, dbName, tableList, 
maxBatchSize)) {
+  private void dropDatabaseCascadePerTable(DropDatabaseRequest req, 
List<String> tableList, int maxBatchSize) 
+      throws TException {
+    String dbNameWithCatalog = prependCatalogToDbName(req.getCatalogName(), 
req.getName(), conf);
+    for (Table table : new TableIterable(
+        this, req.getCatalogName(), req.getName(), tableList, maxBatchSize)) {
       boolean success = false;
       HiveMetaHook hook = getHook(table);
-      if (hook == null) {
-        continue;
-      }
       try {
-        hook.preDropTable(table);
-        client.drop_table_with_environment_context(dbNameWithCatalog, 
table.getTableName(), deleteData, null);
-        hook.commitDropTable(table, deleteData);
+        if (hook != null) {
+          hook.preDropTable(table);
+        }
+        boolean isSoftDelete = req.isSoftDelete() && Boolean.parseBoolean(
+          table.getParameters().getOrDefault(SOFT_DELETE_TABLE, "false"));
+        EnvironmentContext context = null;
+        if (req.isSetTxnId()) {
+          context = new EnvironmentContext();
+          context.putToProperties("txnId", String.valueOf(req.getTxnId()));
+          req.setDeleteManagedDir(false);
+        }
+        client.drop_table_with_environment_context(dbNameWithCatalog, 
table.getTableName(), 
+            req.isDeleteData() && !isSoftDelete, context);
+        if (hook != null) {
+          hook.commitDropTable(table, req.isDeleteData());
+        }
         success = true;
       } finally {
-        if (!success) {
+        if (!success && hook != null) {
           hook.rollbackDropTable(table);
         }
       }
     }
-    client.drop_database(dbNameWithCatalog, deleteData, true);
+    client.drop_database_req(req);
   }
 
   /**
    * Handles dropDatabase by invoking drop_database in HMS.
    * Useful when table list in DB can fit in memory, it will retrieve all 
tables at once and
    * call drop_database once. Also handles drop_table hooks.
-   * @param catName
-   * @param dbName
+   * @param req
    * @param tableList
-   * @param deleteData
    * @throws TException
    */
-  private void dropDatabaseCascadePerDb(String catName, String dbName, 
List<String> tableList,
-                                        boolean deleteData) throws TException {
-    String dbNameWithCatalog = prependCatalogToDbName(catName, dbName, conf);
-    List<Table> tables = getTableObjectsByName(catName, dbName, tableList);
+  private void dropDatabaseCascadePerDb(DropDatabaseRequest req, List<String> 
tableList) throws TException {

Review Comment:
   that remains if soft delete is disabled, otherwise, we'll be locking just 
tables/not DB with an appropriate type of lock.  
   allTablesWithSuffix is an optimization, if all tables under DB are 
soft-delete eligible - grad just DB-level lock. 





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

    Worklog Id:     (was: 761719)
    Time Spent: 1h 50m  (was: 1h 40m)

> Non blocking DROP DATABASE implementation
> -----------------------------------------
>
>                 Key: HIVE-26149
>                 URL: https://issues.apache.org/jira/browse/HIVE-26149
>             Project: Hive
>          Issue Type: Task
>            Reporter: Denys Kuzmenko
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to