[ 
https://issues.apache.org/jira/browse/HDFS-16645?focusedWorklogId=795406&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-795406
 ]

ASF GitHub Bot logged work on HDFS-16645:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jul/22 19:49
            Start Date: 26/Jul/22 19:49
    Worklog Time Spent: 10m 
      Work Description: jojochuang commented on code in PR #4518:
URL: https://github.com/apache/hadoop/pull/4518#discussion_r930353295


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/server/TestJournal.java:
##########
@@ -535,4 +538,43 @@ public void 
testFormatNonEmptyStorageDirectoriesWhenforceOptionIsTrue()
       fail("Format should be success with force option.");
     }
   }
+
+  @Test
+  public void testMultiInProgressSegment() throws Exception {
+    journal.newEpoch(FAKE_NSINFO, 1);
+
+    // Start a segment at txid 1, and write a batch of 3 txns.
+    journal.startLogSegment(makeRI(1), 1,
+        NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
+    journal.journal(makeRI(2), 1, 1, 3,
+        QJMTestUtil.createTxnData(1, 3));
+
+    GenericTestUtils.assertExists(
+        journal.getStorage().getInProgressEditLog(1));
+
+    // Try to start new segment at txid 6, this should abort old segment and
+    // then succeed, allowing us to write txid 6-9.
+    journal.startLogSegment(makeRI(3), 6,
+        NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION);
+    journal.journal(makeRI(4), 6, 6, 3,
+        QJMTestUtil.createTxnData(6, 3));
+
+    // The old segment should *not* be finalized.
+    GenericTestUtils.assertExists(
+        journal.getStorage().getInProgressEditLog(1));
+    GenericTestUtils.assertExists(
+        journal.getStorage().getInProgressEditLog(6));
+
+    try {
+      RemoteEditLogManifest remoteEditLogManifest =
+          journal.getEditLogManifest(1, true);
+      assertNotNull(remoteEditLogManifest);
+      assertEquals(1, remoteEditLogManifest.getLogs().size());
+      RemoteEditLog remoteEditLog = remoteEditLogManifest.getLogs().get(0);
+      assertTrue(remoteEditLog.isInProgress());
+      assertEquals(6, remoteEditLog.getStartTxId());
+    } catch (IOException e) {
+      fail();
+    }

Review Comment:
   No need to catch IOException and throw. Just let it throw.
   ```suggestion
         RemoteEditLogManifest remoteEditLogManifest =
             journal.getEditLogManifest(1, true);
         assertNotNull(remoteEditLogManifest);
         assertEquals(1, remoteEditLogManifest.getLogs().size());
         RemoteEditLog remoteEditLog = remoteEditLogManifest.getLogs().get(0);
         assertTrue(remoteEditLog.isInProgress());
         assertEquals(6, remoteEditLog.getStartTxId());
   ```





Issue Time Tracking
-------------------

    Worklog Id:     (was: 795406)
    Time Spent: 1h 10m  (was: 1h)

> Multi inProgress segments caused "Invalid log manifest"
> -------------------------------------------------------
>
>                 Key: HDFS-16645
>                 URL: https://issues.apache.org/jira/browse/HDFS-16645
>             Project: Hadoop HDFS
>          Issue Type: Bug
>            Reporter: ZanderXu
>            Assignee: ZanderXu
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> {code:java}
> java.lang.IllegalStateException: Invalid log manifest (log [1-? 
> (in-progress)] overlaps [6-? (in-progress)])[[6-? (in-progress)], [1-? 
> (in-progress)]] CommittedTxId: 0 
>         at 
> org.apache.hadoop.hdfs.server.protocol.RemoteEditLogManifest.checkState(RemoteEditLogManifest.java:62)
>       at 
> org.apache.hadoop.hdfs.server.protocol.RemoteEditLogManifest.<init>(RemoteEditLogManifest.java:46)
>       at 
> org.apache.hadoop.hdfs.qjournal.server.Journal.getEditLogManifest(Journal.java:740)
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to