You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/01/06 16:38:32 UTC

[GitHub] [hive] pvargacl commented on a change in pull request #1831: HIVE-24586: Rename compaction 'attempted' status

pvargacl commented on a change in pull request #1831:
URL: https://github.com/apache/hive/pull/1831#discussion_r552788738



##########
File path: ql/src/test/org/apache/hadoop/hive/ql/txn/compactor/TestInitiator.java
##########
@@ -1159,6 +1163,42 @@ public void resolveUserToRunAs() throws Exception {
     Assert.assertNotEquals(userFromConf, initiator.resolveUserToRunAs(tblNameOwners, t, null));
   }
 
+  @Test public void testInitiatorFailure() throws Exception {
+    String tableName = "my_table";
+    Table t = newTable("default", tableName, false);
+
+    HiveConf.setIntVar(conf, HiveConf.ConfVars.HIVE_COMPACTOR_ABORTEDTXN_THRESHOLD, 1);
+
+    // 2 aborts
+    for (int i = 0; i < 2; i++) {
+      long txnid = openTxn();
+      LockComponent comp = new LockComponent(LockType.SHARED_WRITE, LockLevel.TABLE, "default");
+      comp.setTablename(tableName);
+      comp.setOperationType(DataOperationType.UPDATE);
+      List<LockComponent> components = new ArrayList<LockComponent>(1);
+      components.add(comp);
+      LockRequest req = new LockRequest(components, "me", "localhost");
+      req.setTxnid(txnid);
+      LockResponse res = txnHandler.lock(req);
+      txnHandler.abortTxn(new AbortTxnRequest(txnid));
+    }
+
+    // run and fail initiator
+    Initiator initiator = Mockito.spy(new Initiator());
+    initiator.setThreadId((int) t.getId());
+    initiator.setConf(conf);
+    initiator.init(new AtomicBoolean(true));
+    doThrow(new RuntimeException()).when(initiator).resolveValidWriteIds(any());
+    initiator.run();
+
+    // verify status of table compaction
+    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
+    List<ShowCompactResponseElement> compacts = rsp.getCompacts();
+    Assert.assertEquals(1, compacts.size());
+    Assert.assertEquals("did not initiate", compacts.get(0).getState());

Review comment:
       I just noticed that in Initiator.scheduleCompactionIfRequired the exception is not passed to CompactionInfo, so it won't get saved. Could you also fix that, and here you could check if it was saved correctly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org