Skip to content

HIVE-29522: Prevent cleaner from creating COMPLETED_COMPACTIONS entries for soft-deleted ACID tables#6399

Open
VenuReddy2103 wants to merge 1 commit intoapache:masterfrom
VenuReddy2103:HIVE-29522
Open

HIVE-29522: Prevent cleaner from creating COMPLETED_COMPACTIONS entries for soft-deleted ACID tables#6399
VenuReddy2103 wants to merge 1 commit intoapache:masterfrom
VenuReddy2103:HIVE-29522

Conversation

@VenuReddy2103
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

When a table is soft deleted, soft_delete flag is recorded in COMPACTION_QUEUE table properties. This flag is used in MarkCleanedFunction

Why are the changes needed?

When the configuration property hive.acid.createtable.softdelete is set to true, deletion of ACID table data is performed asynchronously by a background cleaner thread.
As part of this process, the cleaner thread removes entry corresponding to the acid table from the COMPACTION_QUEUE and records a completion entry in the COMPLETED_COMPACTIONS table using org.apache.hadoop.hive.metastore.txn.TxnStore#markCleaned().
However, by the time this operation is executed, the associated ACID table has already been deleted (soft-deleted) in HMS. As a result, a COMPLETED_COMPACTIONS entry is created for a table that no longer exists.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Tested manually

@sonarqubecloud
Copy link
Copy Markdown

}

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

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
    }

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants