This is an automated email from the ASF dual-hosted git repository.
tchoi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git
The following commit(s) were added to refs/heads/master by this push:
new 1fb439f8be6 HIVE-21213: Update integration test to mark compactions as
complete instead of aborted. (#4671)
1fb439f8be6 is described below
commit 1fb439f8be6d0b248835e4e137e8e9adcc0f4e9b
Author: Rakshith C <[email protected]>
AuthorDate: Fri Sep 8 07:29:04 2023 +0530
HIVE-21213: Update integration test to mark compactions as complete instead
of aborted. (#4671)
---
.../parse/TestReplicationScenariosAcidTables.java | 29 ++++++++++++++--------
1 file changed, 18 insertions(+), 11 deletions(-)
diff --git
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
index d63d8d07649..93fd5f0cbc9 100644
---
a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
+++
b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/parse/TestReplicationScenariosAcidTables.java
@@ -29,16 +29,18 @@ import org.apache.hadoop.hive.conf.HiveConf;
import org.apache.hadoop.hive.metastore.TableType;
import org.apache.hadoop.hive.metastore.ReplChangeManager;
import org.apache.hadoop.hive.metastore.Warehouse;
-import org.apache.hadoop.hive.metastore.api.AbortCompactionRequest;
+import org.apache.hadoop.hive.metastore.api.CompactionInfoStruct;
import org.apache.hadoop.hive.metastore.api.CompactionRequest;
import org.apache.hadoop.hive.metastore.api.CompactionType;
import org.apache.hadoop.hive.metastore.api.Database;
import org.apache.hadoop.hive.metastore.api.AbortTxnRequest;
import org.apache.hadoop.hive.metastore.api.AbortTxnsRequest;
+import org.apache.hadoop.hive.metastore.api.MetaException;
import org.apache.hadoop.hive.metastore.api.Partition;
import org.apache.hadoop.hive.metastore.api.Table;
import org.apache.hadoop.hive.metastore.conf.MetastoreConf;
import
org.apache.hadoop.hive.metastore.messaging.json.gzip.GzipJSONMessageEncoder;
+import org.apache.hadoop.hive.metastore.txn.CompactionInfo;
import org.apache.hadoop.hive.metastore.txn.TxnStore;
import org.apache.hadoop.hive.metastore.txn.TxnUtils;
import org.apache.hadoop.hive.metastore.InjectableBehaviourObjectStore;
@@ -4037,7 +4039,7 @@ public class TestReplicationScenariosAcidTables extends
BaseReplicationScenarios
throws Throwable {
HiveConf hiveConf = new HiveConf(primary.getConf());
TxnStore txnHandler = TxnUtils.getTxnStore(hiveConf);
- abortPreviousCompactions(txnHandler, hiveConf);
+ markPreviousCompactionsAsComplete(txnHandler, hiveConf);
CompactionRequest rqst = new CompactionRequest(dbName, tblName,
compactionType);
rqst.setPartitionname(partName);
txnHandler.compact(rqst);
@@ -4046,19 +4048,24 @@ public class TestReplicationScenariosAcidTables extends
BaseReplicationScenarios
runCleaner(hiveConf);
}
- private void abortPreviousCompactions(TxnStore txnHandler, HiveConf conf)
throws Throwable {
+ private void markPreviousCompactionsAsComplete(TxnStore txnHandler, HiveConf
conf) throws Throwable {
Connection conn = TestTxnDbUtil.getConnection(conf);
Statement stmt = conn.createStatement();
- ResultSet rs = stmt.executeQuery("select * from COMPACTION_QUEUE");
- List<Long> compactionsToAbort = new ArrayList<>();
+ ResultSet rs = stmt.executeQuery("select CQ_ID from COMPACTION_QUEUE");
+ List<Long> openCompactionIds = new ArrayList<>();
while (rs.next()) {
- compactionsToAbort.add(rs.getLong("CQ_ID"));
- }
- if (!compactionsToAbort.isEmpty()) {
- AbortCompactionRequest rqst = new AbortCompactionRequest();
- rqst.setCompactionIds(compactionsToAbort);
- txnHandler.abortCompactions(rqst);
+ openCompactionIds.add(rs.getLong(1));
}
+ openCompactionIds.forEach(id->{
+ CompactionInfoStruct compactionInfoStruct = new CompactionInfoStruct();
+ compactionInfoStruct.setId(id);
+ CompactionInfo compactionInfo =
CompactionInfo.compactionStructToInfo(compactionInfoStruct);
+ try {
+ txnHandler.markCompacted(compactionInfo);
+ } catch (MetaException e) {
+ throw new RuntimeException(e);
+ }
+ });
}
private FileStatus[] getDirsInTableLoc(WarehouseInstance wh, String db,
String table) throws Throwable {