[
https://issues.apache.org/jira/browse/HIVE-26414?focusedWorklogId=793599&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-793599
]
ASF GitHub Bot logged work on HIVE-26414:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 21/Jul/22 08:33
Start Date: 21/Jul/22 08:33
Worklog Time Spent: 10m
Work Description: deniskuzZ commented on code in PR #3457:
URL: https://github.com/apache/hive/pull/3457#discussion_r926391951
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
Review Comment:
could we pass a `Context ctx` here instead of initializing the destination
table when acquiring locks?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
Review Comment:
shouldn't we check that this was a CTAS operation? do we only need to
cleanup if an exclusive lock is enabled?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
+ if (destinationTable != null) {
+ try {
+ CompactionRequest rqst = new CompactionRequest(
+ destinationTable.getDbName(),
destinationTable.getTableName(), CompactionType.MAJOR);
+
rqst.setRunas(TxnUtils.findUserToRunAs(destinationTable.getSd().getLocation(),
+ destinationTable.getTTable(), conf));
+
+ rqst.putToProperties("location",
destinationTable.getSd().getLocation());
Review Comment:
use hive_metastoreConstants.META_TABLE_LOCATION?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -29,19 +29,10 @@ Licensed to the Apache Software Foundation (ASF) under one
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.LockComponentBuilder;
import org.apache.hadoop.hive.metastore.LockRequestBuilder;
-import org.apache.hadoop.hive.metastore.api.LockComponent;
-import org.apache.hadoop.hive.metastore.api.LockResponse;
-import org.apache.hadoop.hive.metastore.api.LockState;
-import org.apache.hadoop.hive.metastore.api.MetaException;
-import org.apache.hadoop.hive.metastore.api.NoSuchLockException;
-import org.apache.hadoop.hive.metastore.api.NoSuchTxnException;
-import org.apache.hadoop.hive.metastore.api.TxnAbortedException;
-import org.apache.hadoop.hive.metastore.api.TxnToWriteId;
-import org.apache.hadoop.hive.metastore.api.CommitTxnRequest;
-import org.apache.hadoop.hive.metastore.api.DataOperationType;
-import org.apache.hadoop.hive.metastore.api.GetOpenTxnsResponse;
-import org.apache.hadoop.hive.metastore.api.TxnType;
+import org.apache.hadoop.hive.metastore.api.*;
Review Comment:
please avoid wildcard imports
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
+ if (destinationTable != null) {
+ try {
+ CompactionRequest rqst = new CompactionRequest(
+ destinationTable.getDbName(),
destinationTable.getTableName(), CompactionType.MAJOR);
+
rqst.setRunas(TxnUtils.findUserToRunAs(destinationTable.getSd().getLocation(),
+ destinationTable.getTTable(), conf));
+
+ rqst.putToProperties("location",
destinationTable.getSd().getLocation());
+ rqst.putToProperties("ifPurge", Boolean.toString(true));
+ TxnStore txnHandler = TxnUtils.getTxnStore(conf);
+ txnHandler.submitForCleanup(rqst,
destinationTable.getTTable().getWriteId(), getCurrentTxnId());
+ } catch (InterruptedException | IOException | MetaException e) {
+ throw new RuntimeException("Not able to submit cleanup operation of
directory written by CTAS");
Review Comment:
should we catch just InterruptedException | IOException and re-throw
MetaException here?
##########
ql/src/java/org/apache/hadoop/hive/ql/parse/SemanticAnalyzer.java:
##########
@@ -7852,6 +7852,10 @@ protected Operator genFileSinkPlan(String dest, QB qb,
Operator input)
throw new SemanticException("Error while getting the full qualified
path for the given directory: " + ex.getMessage());
}
}
+
+ if (!isNonNativeTable &&
AcidUtils.isTransactionalTable(destinationTable) && qb.isCTAS()) {
Review Comment:
is `!isNonNativeTable` required to exclude Iceberg tables?
##########
ql/src/java/org/apache/hadoop/hive/ql/lockmgr/DbTxnManager.java:
##########
@@ -485,6 +480,26 @@ private void clearLocksAndHB() {
stopHeartbeat();
}
+ private void cleanupDirForCTAS() {
+ if (HiveConf.getBoolVar(conf, HiveConf.ConfVars.TXN_CTAS_X_LOCK)) {
+ if (destinationTable != null) {
+ try {
+ CompactionRequest rqst = new CompactionRequest(
+ destinationTable.getDbName(),
destinationTable.getTableName(), CompactionType.MAJOR);
+
rqst.setRunas(TxnUtils.findUserToRunAs(destinationTable.getSd().getLocation(),
+ destinationTable.getTTable(), conf));
+
+ rqst.putToProperties("location",
destinationTable.getSd().getLocation());
+ rqst.putToProperties("ifPurge", Boolean.toString(true));
Review Comment:
would be good if we move "ifPurge" under constants as well
Issue Time Tracking
-------------------
Worklog Id: (was: 793599)
Time Spent: 1h 20m (was: 1h 10m)
> Aborted/Cancelled CTAS operations must initiate cleanup of uncommitted data
> ---------------------------------------------------------------------------
>
> Key: HIVE-26414
> URL: https://issues.apache.org/jira/browse/HIVE-26414
> Project: Hive
> Issue Type: Improvement
> Reporter: Sourabh Badhya
> Assignee: Sourabh Badhya
> Priority: Major
> Labels: pull-request-available
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> When a CTAS query fails before creation of table and after writing the data,
> the data is present in the directory and not cleaned up currently by the
> cleaner or any other mechanism currently. This is because the cleaner
> requires a table corresponding to what its cleaning. In order surpass such a
> situation, we can directly pass the relevant information to the cleaner so
> that such uncommitted data is deleted.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)