Skip to content

Commit d15ae24

Browse files
author
Venu Reddy
committed
HIVE-29522: Prevent cleaner from creating COMPLETED_COMPACTIONS entries for soft-deleted ACID tables
1 parent 291cfd1 commit d15ae24

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

ql/src/java/org/apache/hadoop/hive/ql/txn/compactor/handler/CompactionCleaner.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ private void clean(CompactionInfo ci, long minOpenTxn, boolean metricsEnabled) t
158158
cleanUsingAcidDir(ci, t, path, cleanerWaterMark);
159159
}
160160
} else {
161+
ci.setSoftDelete(true);
161162
cleanUsingLocation(ci, location, false);
162163
}
163164
} catch (Exception e) {

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/entities/CompactionInfo.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public class CompactionInfo implements Comparable<CompactionInfo> {
6969
public int numberOfBuckets = 0;
7070
public String orderByClause;
7171
public long minOpenWriteTxnId = 0;
72+
public boolean softDelete;
7273

7374
/**
7475
* The highest write id that the compaction job will pay attention to.
@@ -190,6 +191,7 @@ public String toString() {
190191
.append("numberOfBuckets", numberOfBuckets)
191192
.append("orderByClause", orderByClause)
192193
.append("minOpenWriteTxnId", minOpenWriteTxnId)
194+
.append("softDelete", softDelete)
193195
.build();
194196
}
195197

@@ -368,4 +370,12 @@ public void setWriteIds(boolean hasUncompactedAborts, Set<Long> writeIds) {
368370
public boolean isAbortedTxnCleanup() {
369371
return type == CompactionType.ABORT_TXN_CLEANUP;
370372
}
373+
374+
public void setSoftDelete(boolean softDelete) {
375+
this.softDelete = softDelete;
376+
}
377+
378+
public boolean isSoftDelete() {
379+
return softDelete;
380+
}
371381
}

standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/txn/jdbc/functions/MarkCleanedFunction.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public MarkCleanedFunction(CompactionInfo info) {
5050
public Void execute(MultiDataSourceJdbcResource jdbcResource) throws MetaException {
5151
NamedParameterJdbcTemplate jdbcTemplate = jdbcResource.getJdbcTemplate();
5252
MapSqlParameterSource param;
53-
if (!info.isAbortedTxnCleanup()) {
53+
if (!info.isAbortedTxnCleanup() && !info.isSoftDelete()) {
5454
param = new MapSqlParameterSource()
5555
.addValue("id", info.id)
5656
.addValue("succeeded", Character.toString(SUCCEEDED_STATE), Types.CHAR);
@@ -85,6 +85,10 @@ public Void execute(MultiDataSourceJdbcResource jdbcResource) throws MetaExcepti
8585
*/
8686
removeCompactionAndAbortRetryEntries(info, jdbcTemplate);
8787

88+
if (info.isSoftDelete()) {
89+
return null;
90+
}
91+
8892
if (!info.isAbortedTxnCleanup()) {
8993
// Remove entries from completed_txn_components as well, so we don't start looking there
9094
// again but only up to the highest write ID include in this compaction job.
@@ -175,7 +179,7 @@ private void removeCompactionAndAbortRetryEntries(CompactionInfo info, NamedPara
175179
String deleteQuery = """
176180
DELETE FROM "COMPACTION_QUEUE" WHERE "CQ_ID" = :id
177181
""";
178-
if (!info.isAbortedTxnCleanup()) {
182+
if (!info.isAbortedTxnCleanup() && !info.isSoftDelete()) {
179183
deleteQuery += """
180184
OR ("CQ_DATABASE" = :db AND "CQ_TABLE" = :table
181185
AND (:partition is NULL OR "CQ_PARTITION" = :partition)

0 commit comments

Comments
 (0)