Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.hadoop.hive.metastore;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hive.common.AcidConstants;
import org.apache.hadoop.hive.metastore.api.CompactionRequest;
import org.apache.hadoop.hive.metastore.api.CompactionType;
import org.apache.hadoop.hive.metastore.api.Database;
Expand Down Expand Up @@ -91,6 +92,7 @@ public void onDropTable(DropTableEvent tableEvent) throws MetaException {
rqst.setRunas(TxnUtils.findUserToRunAs(table.getSd().getLocation(), table, conf));
rqst.putToProperties("location", table.getSd().getLocation());
rqst.putToProperties("ifPurge", Boolean.toString(isMustPurge(tableEvent.getEnvironmentContext(), table)));
rqst.putToProperties(AcidConstants.SOFT_DELETE_TABLE, Boolean.TRUE.toString());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is that really needed?
check the CompactionCleaner#cleanUsingLocation(ci, location, false) maybe pass flag there?

txnHandler.submitForCleanup(rqst, table.getWriteId(), currentTxn);
} catch (InterruptedException | IOException e) {
throwMetaException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.hive.metastore.txn.entities;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.hadoop.hive.common.AcidConstants;
import org.apache.hadoop.hive.common.ValidCompactorWriteIdList;
import org.apache.hadoop.hive.metastore.api.CompactionInfoStruct;
import org.apache.hadoop.hive.metastore.api.CompactionType;
Expand Down Expand Up @@ -368,4 +369,8 @@ public void setWriteIds(boolean hasUncompactedAborts, Set<Long> writeIds) {
public boolean isAbortedTxnCleanup() {
return type == CompactionType.ABORT_TXN_CLEANUP;
}

public boolean isSoftDelete() {
return "true".equalsIgnoreCase(getProperty(AcidConstants.SOFT_DELETE_TABLE));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe Boolean.parseBoolean

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public MarkCleanedFunction(CompactionInfo info) {
public Void execute(MultiDataSourceJdbcResource jdbcResource) throws MetaException {
NamedParameterJdbcTemplate jdbcTemplate = jdbcResource.getJdbcTemplate();
MapSqlParameterSource param;
if (!info.isAbortedTxnCleanup()) {
if (!info.isAbortedTxnCleanup() && !info.isSoftDelete()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just add at the top

if (!info.isSoftDelete()) {
      removeTxnComponents(info, jdbcResource);
      return
    }

param = new MapSqlParameterSource()
.addValue("id", info.id)
.addValue("succeeded", Character.toString(SUCCEEDED_STATE), Types.CHAR);
Expand Down Expand Up @@ -85,7 +85,7 @@ public Void execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExcepti
*/
removeCompactionAndAbortRetryEntries(info, jdbcTemplate);

if (!info.isAbortedTxnCleanup()) {
if (!info.isAbortedTxnCleanup() && !info.isSoftDelete()) {
// Remove entries from completed_txn_components as well, so we don't start looking there
// again but only up to the highest write ID include in this compaction job.
//highestWriteId will be NULL in upgrade scenarios
Expand Down Expand Up @@ -121,7 +121,9 @@ public Void execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExcepti
}

// Do cleanup of metadata in TXN_COMPONENTS table.
removeTxnComponents(info, jdbcResource);
if (!info.isSoftDelete()) {
removeTxnComponents(info, jdbcResource);
}
return null;
}

Expand Down Expand Up @@ -175,7 +177,7 @@ private void removeCompactionAndAbortRetryEntries(CompactionInfo info, NamedPara
String deleteQuery = """
DELETE FROM "COMPACTION_QUEUE" WHERE "CQ_ID" = :id
""";
if (!info.isAbortedTxnCleanup()) {
if (!info.isAbortedTxnCleanup() && !info.isSoftDelete()) {
deleteQuery += """
OR ("CQ_DATABASE" = :db AND "CQ_TABLE" = :table
AND (:partition is NULL OR "CQ_PARTITION" = :partition)
Expand Down
Loading