[
https://issues.apache.org/jira/browse/HIVE-26149?focusedWorklogId=763381&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-763381
]
ASF GitHub Bot logged work on HIVE-26149:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 28/Apr/22 09:16
Start Date: 28/Apr/22 09:16
Worklog Time Spent: 10m
Work Description: pvary commented on code in PR #3220:
URL: https://github.com/apache/hive/pull/3220#discussion_r860668405
##########
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:
Would this be better:
```
LockType lockType = WriteEntity.WriteType.DDL_NO_LOCK;
if (isTableLockNeeded) {
lockType = AcidUtils.isTableSoftDeleteEnabled(table, conf) ?
WriteEntity.WriteType.DDL_EXCL_WRITE :
WriteEntity.WriteType.DDL_EXCLUSIVE;
}
outputs.add(new WriteEntity(table, lockType));
```
I think having too many `:` and `?` is really hard to read.
Issue Time Tracking
-------------------
Worklog Id: (was: 763381)
Time Spent: 2h (was: 1h 50m)
> 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
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian Jira
(v8.20.7#820007)