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

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

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


##########
ql/src/java/org/apache/hadoop/hive/ql/ddl/database/drop/DropDatabaseAnalyzer.java:
##########
@@ -49,28 +52,36 @@ public void analyzeInternal(ASTNode root) throws 
SemanticException {
     String databaseName = unescapeIdentifier(root.getChild(0).getText());
     boolean ifExists = root.getFirstChildWithType(HiveParser.TOK_IFEXISTS) != 
null;
     boolean cascade = root.getFirstChildWithType(HiveParser.TOK_CASCADE) != 
null;
+    boolean isSoftDelete = HiveConf.getBoolVar(conf, 
HiveConf.ConfVars.HIVE_ACID_LOCKLESS_READS_ENABLED);
 
     Database database = getDatabase(databaseName, !ifExists);
     if (database == null) {
       return;
     }
-
     // if cascade=true, then we need to authorize the drop table action as 
well, and add the tables to the outputs
+    boolean allTablesWithSuffix = false;
     if (cascade) {
       try {
-        for (Table table : db.getAllTableObjects(databaseName)) {
-          // We want no lock here, as the database lock will cover the tables,
-          // and putting a lock will actually cause us to deadlock on 
ourselves.
-          outputs.add(new WriteEntity(table, 
WriteEntity.WriteType.DDL_NO_LOCK));
+        List<Table> tables = db.getAllTableObjects(databaseName);
+        allTablesWithSuffix = tables.stream().allMatch(
+            table -> AcidUtils.isTableSoftDeleteEnabled(table, conf));
+        for (Table table : tables) {
+          // Optimization used to limit number of requested locks. Check if 
table lock is needed or we could get away with single DB level lock,
+          boolean isTableLockNeeded = isSoftDelete && !allTablesWithSuffix;
+          outputs.add(new WriteEntity(table, isTableLockNeeded ?
+            AcidUtils.isTableSoftDeleteEnabled(table, conf) ?
+                WriteEntity.WriteType.DDL_EXCL_WRITE : 
WriteEntity.WriteType.DDL_EXCLUSIVE :
+            WriteEntity.WriteType.DDL_NO_LOCK));

Review Comment:
   refactored





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

    Worklog Id:     (was: 763483)
    Time Spent: 2h 20m  (was: 2h 10m)

> 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: 2h 20m
>  Remaining Estimate: 0h
>




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

Reply via email to