Skip to content

Conversation

@tomscut
Copy link
Contributor

@tomscut tomscut commented Apr 22, 2022

JIRA: HDFS-16557.

The lastTxId of an inprogress EditLogInputStream lastTxId isn't necessarily HdfsServerConstants.INVALID_TXID. We can determine its status directly by EditLogInputStream#isInProgress.

We introduced [SBN READ], and set dfs.ha.tail-edits.in-progress=true. Then bootstrapStandby a new Namenode, the EditLogInputStream of inProgress is misjudged, resulting in a gap check failure, which causes bootstrapStandby to fail.

hdfs namenode -bootstrapStandby
image
image

@tomscut tomscut changed the title HDFS-16557. BootstrapStandby failed because of checking Gap for inprogress EditLogInputStream HDFS-16557. BootstrapStandby failed because of checking gap for inprogress EditLogInputStream Apr 22, 2022
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 12m 53s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 38m 52s trunk passed
+1 💚 compile 1m 43s trunk passed with JDK Ubuntu-11.0.14.1+1-Ubuntu-0ubuntu1.20.04
+1 💚 compile 1m 37s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 checkstyle 1m 25s trunk passed
+1 💚 mvnsite 1m 44s trunk passed
+1 💚 javadoc 1m 24s trunk passed with JDK Ubuntu-11.0.14.1+1-Ubuntu-0ubuntu1.20.04
+1 💚 javadoc 1m 47s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 3m 40s trunk passed
+1 💚 shadedclient 23m 10s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 23s the patch passed
+1 💚 compile 1m 25s the patch passed with JDK Ubuntu-11.0.14.1+1-Ubuntu-0ubuntu1.20.04
+1 💚 javac 1m 25s the patch passed
+1 💚 compile 1m 20s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 javac 1m 20s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 0s the patch passed
+1 💚 mvnsite 1m 26s the patch passed
+1 💚 javadoc 0m 59s the patch passed with JDK Ubuntu-11.0.14.1+1-Ubuntu-0ubuntu1.20.04
+1 💚 javadoc 1m 34s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 3m 19s the patch passed
+1 💚 shadedclient 22m 40s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 248m 17s hadoop-hdfs in the patch passed.
+1 💚 asflicense 1m 13s The patch does not generate ASF License warnings.
371m 9s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/1/artifact/out/Dockerfile
GITHUB PR #4219
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell
uname Linux 762330a41f0c 4.15.0-169-generic #177-Ubuntu SMP Thu Feb 3 10:50:38 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / abd27315b22d09607203cbe3ff1fbb9ed8b47ca2
Default Java Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Ubuntu-11.0.14.1+1-Ubuntu-0ubuntu1.20.04 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/1/testReport/
Max. process+thread count 3553 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/1/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org

This message was automatically generated.

@tomscut
Copy link
Contributor Author

tomscut commented Apr 24, 2022

Thanks @ashutoshcipher for your review.

@tomscut
Copy link
Contributor Author

tomscut commented Apr 24, 2022

Hi @tasanuma @xkrogen @sunchao , could you please have a look? Thanks a lot.

@tomscut
Copy link
Contributor Author

tomscut commented Apr 27, 2022

Hi @ayushtkn @Hexiaoqiao @ferhui , could you please also take a look? Thanks a lot.

Copy link
Contributor

@xkrogen xkrogen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems right to me, but I don't fully understand what went wrong to cause the error. Can you explain more fully? Why did we previously make the assumption that INVALID_TXID meant in-progress, and what has changed to make that not true / what happened in your specific scenario to cause that not to be true?

@tomscut
Copy link
Contributor Author

tomscut commented Apr 30, 2022

This seems right to me, but I don't fully understand what went wrong to cause the error. Can you explain more fully? Why did we previously make the assumption that INVALID_TXID meant in-progress, and what has changed to make that not true / what happened in your specific scenario to cause that not to be true?

Thank you @xkrogen very much for your review.

After introducing [SBN READ], we updated the configuration: dfs.ha.tail-edits.in-progress=true.

Then when we bootstrapStandby, we will encounter something like this:

  1. We need to start an Observer Namenode, so we execute bootstrapStandby before start it. This will automatically pull the latest FSImage from the Active Namenode and check whether the edits in the journals has a gap based on the lastTxid of the FSImage.

  2. Assume that the txid of the latest FSImage is x, and editslogs from x in journals is in InProgress state, FSEditLog#checkForGaps will be skipped. Because the lastTxid of the InProgress EditLogInputStream is not HdfsServerConstants.INVALID_TXID, but a specific number.

  3. However, between x and txID currently being written in journal, there is finalize Edit log, and bootstrapStandby can execute normally.

The lastTxId of an InProgress EditLogInputStream isn't always as HdfsServerConstants.INVALID_TXID, could also be a specific number.

@tomscut
Copy link
Contributor Author

tomscut commented Apr 30, 2022

Hi @xkrogen , to make the change safe, we can change the condition from:
if(next == HdfsServerConstants.INVALID_TXID)
to
if(next == HdfsServerConstants.INVALID_TXID || elis.isInProgress())

Do you think it's necessary?

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 12m 59s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 37m 45s trunk passed
+1 💚 compile 1m 42s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 compile 1m 36s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 checkstyle 1m 26s trunk passed
+1 💚 mvnsite 1m 45s trunk passed
+1 💚 javadoc 1m 26s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javadoc 1m 50s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 3m 41s trunk passed
+1 💚 shadedclient 23m 3s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 25s the patch passed
+1 💚 compile 1m 25s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javac 1m 25s the patch passed
+1 💚 compile 1m 21s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 javac 1m 21s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 2s the patch passed
+1 💚 mvnsite 1m 27s the patch passed
+1 💚 javadoc 0m 58s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javadoc 1m 30s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 3m 23s the patch passed
+1 💚 shadedclient 22m 16s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 247m 28s hadoop-hdfs in the patch passed.
+1 💚 asflicense 1m 14s The patch does not generate ASF License warnings.
368m 40s
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/2/artifact/out/Dockerfile
GITHUB PR #4219
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell
uname Linux e1b95ddc93cd 4.15.0-169-generic #177-Ubuntu SMP Thu Feb 3 10:50:38 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 6e602e9e05a17e8ee69124dec08a81a96eab627e
Default Java Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/2/testReport/
Max. process+thread count 3067 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/2/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org

This message was automatically generated.

@tomscut
Copy link
Contributor Author

tomscut commented May 21, 2022

Hi @xkrogen , please take a look if you have enough bandwidth. Thanks a lot.

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 38s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 37m 58s trunk passed
+1 💚 compile 1m 43s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 compile 1m 37s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 checkstyle 1m 23s trunk passed
+1 💚 mvnsite 1m 43s trunk passed
+1 💚 javadoc 1m 26s trunk passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javadoc 1m 50s trunk passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 3m 40s trunk passed
+1 💚 shadedclient 23m 5s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 20s the patch passed
+1 💚 compile 1m 26s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javac 1m 26s the patch passed
+1 💚 compile 1m 19s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 javac 1m 19s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 0s the patch passed
+1 💚 mvnsite 1m 24s the patch passed
+1 💚 javadoc 0m 58s the patch passed with JDK Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1
+1 💚 javadoc 1m 32s the patch passed with JDK Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
+1 💚 spotbugs 3m 20s the patch passed
+1 💚 shadedclient 22m 10s patch has no errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 256m 13s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 1m 12s The patch does not generate ASF License warnings.
365m 17s
Reason Tests
Failed junit tests hadoop.hdfs.tools.TestDFSAdmin
hadoop.hdfs.server.datanode.fsdataset.impl.TestFsDatasetImpl
hadoop.hdfs.server.sps.TestExternalStoragePolicySatisfier
Subsystem Report/Notes
Docker ClientAPI=1.41 ServerAPI=1.41 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/3/artifact/out/Dockerfile
GITHUB PR #4219
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell
uname Linux 99d71330e64c 4.15.0-169-generic #177-Ubuntu SMP Thu Feb 3 10:50:38 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 7a37d95
Default Java Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Multi-JDK versions /usr/lib/jvm/java-11-openjdk-amd64:Private Build-11.0.15+10-Ubuntu-0ubuntu0.20.04.1 /usr/lib/jvm/java-8-openjdk-amd64:Private Build-1.8.0_312-8u312-b07-0ubuntu1~20.04-b07
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/3/testReport/
Max. process+thread count 3850 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-4219/3/console
versions git=2.25.1 maven=3.6.3 spotbugs=4.2.2
Powered by Apache Yetus 0.14.0-SNAPSHOT https://yetus.apache.org

This message was automatically generated.

@ZanderXu
Copy link
Contributor

Thanks @tomscut for your report. Similar with HDFS-14806 ?

@tomscut
Copy link
Contributor Author

tomscut commented May 23, 2022

Thanks @tomscut for your report. Similar with HDFS-14806 ?

Thanks @ZanderXu for your comments. Setting DFS_HA_TAILEDITS_INPROGRESS_KEY to false could solve the problem. But if we correct the logic of judging in-progress EditLogInputStream, it seems more reasonable.

@tomscut
Copy link
Contributor Author

tomscut commented May 28, 2022

Hi @ayushtkn , could you please also take a look at this. Thanks.

@tomscut
Copy link
Contributor Author

tomscut commented Jun 7, 2022

Hi @jojochuang @tasanuma @Hexiaoqiao , could you please also take a look. Thanks.

@tomscut tomscut requested a review from xkrogen June 8, 2022 03:32
@tomscut
Copy link
Contributor Author

tomscut commented Jun 8, 2022

Hi @xkrogen , if you have enough bandwidth, please take a look. Thank you.

@ZanderXu
Copy link
Contributor

ZanderXu commented Jun 9, 2022

Thanks @tomscut , after tracing the code, I think we cannot add elis.isInProgress().

And I will explain my ideas trough questions and answers.
Question one: Why was INVALID_TXID considered in the original code?

  • CheckForGaps method is used to check whether streams contains continuous TXids from fromTxId to toAtLeastTxid
  • LastTxId equals INVALID_TXID means the stream is in progress
  • toAtLeastTxid maybe abnormal value, like Long.MaxValue. So the CheckForGaps method only need to cover the latest inprogress segment.

Question two: What is the difference between INVALID_TXID and is InProgress()?

  • Before introducing [SBN READ], LastTxId equals INVALID_TXID means the stream is in progress. And stream is in progress means it's lastTxId is INVALID_TXID.
  • But after introducing [SBN READ], LastTxId equals INVALID_TXID means the stream is in progress. But stream is in progress cannot mean it's lastTxId is INVALID_TXID. Because introducing getJournaledEdits.
  • So if we add elis.isInProgress() in CheckForGaps, it cannot cover the last writing segments which actual contains latest edit.

Please correct me if anything is wrong.

@tomscut
Copy link
Contributor Author

tomscut commented Jun 10, 2022

Thanks @tomscut , after tracing the code, I think we cannot add elis.isInProgress().

And I will explain my ideas trough questions and answers. Question one: Why was INVALID_TXID considered in the original code?

  • CheckForGaps method is used to check whether streams contains continuous TXids from fromTxId to toAtLeastTxid
  • LastTxId equals INVALID_TXID means the stream is in progress
  • toAtLeastTxid maybe abnormal value, like Long.MaxValue. So the CheckForGaps method only need to cover the latest inprogress segment.

Question two: What is the difference between INVALID_TXID and is InProgress()?

  • Before introducing [SBN READ], LastTxId equals INVALID_TXID means the stream is in progress. And stream is in progress means it's lastTxId is INVALID_TXID.
  • But after introducing [SBN READ], LastTxId equals INVALID_TXID means the stream is in progress. But stream is in progress cannot mean it's lastTxId is INVALID_TXID. Because introducing getJournaledEdits.
  • So if we add elis.isInProgress() in CheckForGaps, it cannot cover the last writing segments which actual contains latest edit.

Please correct me if anything is wrong.

Thanks @ZanderXu for your comment. Please refer to the stack.
image

When we set dfs.ha.tail-edits.in-progress=true, the edits can be read by getJournaledEdits (there is no gap actually) . But there is an GAP exception thrown.

@ZanderXu
Copy link
Contributor

ZanderXu commented Jun 10, 2022

OK, back to BootstrapStandby GAP.
Form this stack information, I got that it try to get streams from 1049837441 to 1050196644. But cannot get the txid 1049842441 from the result streams.
So I think we should to trace the root cause, why can't we find txid 1049842441 in the return result of selectInputStreams(streams, 1049837441, true, true)?

Please correct me if anything is wrong.

@tomscut
Copy link
Contributor Author

tomscut commented Jun 10, 2022

OK, back to BootstrapStandby GAP. Form this stack information, I got that it try to get streams from 1049842441 to 1050196644. But cannot get the txid 1049842441 from the result streams. So I think we should to trace the root cause, why can't we find txid 1049842441 in the return result of selectInputStreams(streams, 1049842441, true, true)?

Please correct me if anything is wrong.

Please refer to the discussion with @xkrogen above.

The root cause is the if condition (if(next == HdfsServerConstants.INVALID_TXID)) that does not enter properly.

@ZanderXu
Copy link
Contributor

ZanderXu commented Jun 10, 2022

Oh, i know, the root cause is that getJournaledEdits returns up to 5000 txids by default. And 1049842441 - 1049837441 = 5000.

It can't reached to 1050196644, so checkForGaps failed.

@ZanderXu
Copy link
Contributor

So in this case, we should change bootstrap logic.
Solution one: set DFS_HA_TAILEDITS_INPROGRESS_KEY to false.
Solution two: call getJournaledEdits multiple times until get the latest txid, and then go to checkgap

@ZanderXu
Copy link
Contributor

As I explained above, change to if (next == HdfsServerConstants.INVALID_TXID || elis.isInProgress()) maybe change the original semantics of the checkgap method.

About my explain, do you have any questions?😁 Discuss together and become more familiar with the relevant logic.

@ZanderXu
Copy link
Contributor

When we set dfs.ha.tail-edits.in-progress=true, the edits can be read by getJournaledEdits (there is no gap actually) . But there is an GAP exception thrown.

I think there is a gap here because bootstrap expects to get 1050196644 txid, but can't find it in the result. So throwing GAP Exception is ok.

@github-actions
Copy link
Contributor

We're closing this stale PR because it has been open for 100 days with no activity. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you feel like this was a mistake, or you would like to continue working on it, please feel free to re-open it and ask for a committer to remove the stale tag and review again.
Thanks all for your contribution.

@github-actions github-actions bot added the Stale label Nov 13, 2025
@github-actions github-actions bot closed this Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants