You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2021/08/09 14:53:51 UTC

[GitHub] [hudi] leesf commented on a change in pull request #3428: [HUDI-2286] Handle the case of failed deltacommit on the metadata table.

leesf commented on a change in pull request #3428:
URL: https://github.com/apache/hudi/pull/3428#discussion_r685266163



##########
File path: hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/functional/TestHoodieBackedMetadata.java
##########
@@ -857,6 +859,62 @@ public void testMetadataOutOfSync() throws Exception {
     validateMetadata(unsyncedClient);
   }
 
+  /**
+   * Test that failure to perform deltacommit on the metadata table does not lead to missed sync.
+   */
+  @Test
+  public void testMetdataTableCommitFailure() throws Exception {
+    init(HoodieTableType.COPY_ON_WRITE);
+    HoodieSparkEngineContext engineContext = new HoodieSparkEngineContext(jsc);
+
+    try (SparkRDDWriteClient client = new SparkRDDWriteClient(engineContext, getWriteConfig(true, true))) {
+      // Write 1
+      String newCommitTime = "001";
+      List<HoodieRecord> records = dataGen.generateInserts(newCommitTime, 20);
+      client.startCommitWithTime(newCommitTime);
+      List<WriteStatus> writeStatuses = client.bulkInsert(jsc.parallelize(records, 1), newCommitTime).collect();
+      assertNoWriteErrors(writeStatuses);
+
+      // Write 2
+      newCommitTime = "002";
+      client.startCommitWithTime(newCommitTime);
+      records = dataGen.generateInserts(newCommitTime, 20);
+      writeStatuses = client.insert(jsc.parallelize(records, 1), newCommitTime).collect();
+      assertNoWriteErrors(writeStatuses);
+    }
+
+    // At this time both commits 001 and 002 must be synced to the metadata table
+    HoodieTableMetaClient metadataMetaClient = HoodieTableMetaClient.builder().setConf(hadoopConf).setBasePath(metadataTableBasePath).build();
+    HoodieActiveTimeline timeline = metadataMetaClient.getActiveTimeline();
+    assertTrue(timeline.containsInstant(new HoodieInstant(false, HoodieTimeline.DELTA_COMMIT_ACTION, "001")));
+    assertTrue(timeline.containsInstant(new HoodieInstant(false, HoodieTimeline.DELTA_COMMIT_ACTION, "002")));
+
+    // Delete the 002 deltacommit completed instant to make it inflight
+    FileCreateUtils.deleteDeltaCommit(metadataTableBasePath, "002");

Review comment:
       would you please clarify in which situation will `001` and `002` committed and synced to metadata table successfully and then `002` becomes inflight?




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org

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