Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-26603: Initiator does not initiate minor compaction for insert-o… #3648

Merged
merged 3 commits into from
Oct 11, 2022
Merged
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 @@ -519,11 +519,6 @@ private CompactionType determineCompactionType(CompactionInfo ci, AcidDirectory
+ ". Found: " + deltas.size() + " deltas, threshold is " + deltaNumThreshold);
return null;
}
if (AcidUtils.isInsertOnlyTable(tblproperties)) {
LOG.debug("Requesting a major compaction for a MM table; found " + deltas.size() + " deltas, threshold is "
+ deltaNumThreshold);
return CompactionType.MAJOR;
}
// If there's no base file, do a major compaction
LOG.debug("Found " + deltas.size() + " delta files, and " + (noBase ? "no" : "has") + " base," +
"requesting " + (noBase ? "major" : "minor") + " compaction");
Expand Down
35 changes: 34 additions & 1 deletion ql/src/test/org/apache/hadoop/hive/ql/TestTxnCommands2.java
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,35 @@ void testInitiatorWithMultipleFailedCompactionsForVariousTblProperties(String tb
countCompacts(txnHandler));
}

@Test
public void testInitiatorWithMinorCompactionForInsertOnlyTable() throws Exception {
String tblName = "insertOnlyTable";
runStatementOnDriver("drop table if exists " + tblName);
runStatementOnDriver("create table " + tblName + " (a INT, b STRING) stored as orc tblproperties('transactional'='true', " +
"'transactional_properties' = 'insert_only')");
hiveConf.setIntVar(HiveConf.ConfVars.HIVE_COMPACTOR_DELTA_NUM_THRESHOLD, 4);
hiveConf.setFloatVar(HiveConf.ConfVars.HIVE_COMPACTOR_DELTA_PCT_THRESHOLD, 1.0f);
for(int i = 0; i < 20; i++) {
//generate enough delta files so that Initiator can trigger auto compaction
runStatementOnDriver("insert into " + tblName + " values(" + (i + 1) + ", 'foo'),(" + (i + 2) + ", 'bar'),(" + (i + 3) + ", 'baz')");
}
MetastoreConf.setBoolVar(hiveConf, MetastoreConf.ConfVars.COMPACTOR_INITIATOR_ON, true);
runInitiator(hiveConf);
runWorker(hiveConf);
runCleaner(hiveConf);

for(int i = 0; i < 5; i++) {
//generate enough delta files so that Initiator can trigger auto compaction
runStatementOnDriver("insert into " + tblName + " values(" + (i + 1) + ", 'foo'),(" + (i + 2) + ", 'bar'),(" + (i + 3) + ", 'baz')");
}
runInitiator(hiveConf);
runWorker(hiveConf);
runCleaner(hiveConf);

verifyDeltaDir(1, tblName, "");
verifyBaseDir(1, tblName, "");
}

/**
* Make sure there's no FileSystem$Cache$Key leak due to UGI use
* @throws Exception
Expand Down Expand Up @@ -3009,6 +3038,10 @@ public void testFullACIDAbortWithManyPartitions() throws Exception {
Assert.assertEquals(stringifyValues(resultData2), rs);
}

private void verifyDeltaDir(int expectedDeltas, String tblName, String partName) throws Exception {
verifyDir(expectedDeltas, tblName, partName, "delta_.*");
}

private void verifyDeleteDeltaDir(int expectedDeltas, String tblName, String partName) throws Exception {
verifyDir(expectedDeltas, tblName, partName, "delete_delta_.*");
}
Expand All @@ -3035,7 +3068,7 @@ private void verifyDir(int expectedDeltas, String tblName, String partName, Stri
}

private void verifyDeltaDirAndResult(int expectedDeltas, String tblName, String partName, int [][] resultData) throws Exception {
verifyDir(expectedDeltas, tblName, partName, "delta_.*");
verifyDeltaDir(expectedDeltas, tblName, partName);
if (partName.equals("p=newpart")) return;

List<String> rs = runStatementOnDriver("select a,b from " + tblName + (partName.isEmpty() ?
Expand Down