Skip to content

HDFS-17850. Reject append() when newGS equals current generation stamp.#8320

Open
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-17850
Open

HDFS-17850. Reject append() when newGS equals current generation stamp.#8320
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-17850

Conversation

@balodesecurity
Copy link

Summary

Fixes a subtle bug where FsDatasetImpl.append() accepted a newGS equal to the replica's current generation stamp. The invariant for any append is that the new generation stamp must be strictly greater than the existing one; allowing newGS == currentGS permits a misbehaving client to re-use the same GS and corrupt replica state silently.

Changes

  • FsDatasetImpl.java: Change newGS < b.getGenerationStamp() to newGS <= b.getGenerationStamp() (one character change).
  • TestFsDatasetImpl.java: Add testAppendRejectsSameGenerationStamp which asserts:
    • newGS == currentGS throws IOException
    • newGS < currentGS throws IOException (pre-existing behavior)
    • newGS > currentGS succeeds (pre-existing behavior)

Test plan

  • TestFsDatasetImpl#testAppendRejectsSameGenerationStamp passes locally ✅
  • Full module build passes (mvn package -pl hadoop-hdfs-project/hadoop-hdfs -am -DskipTests) ✅

Previously FsDatasetImpl.append() only threw IOException when
newGS < replica.getGenerationStamp(), allowing a client bug that
reuses the same GS to silently succeed and corrupt replica state.
Change the check to newGS <= getGenerationStamp() so that equal-GS
appends are rejected with a clear error message, consistent with the
invariant that every append must strictly bump the generation stamp.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@hadoop-yetus
Copy link

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 19m 8s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 42m 38s trunk passed
+1 💚 compile 1m 39s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 1m 48s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 2m 17s trunk passed
+1 💚 mvnsite 1m 58s trunk passed
+1 💚 javadoc 1m 24s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 1m 24s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 4m 6s trunk passed
+1 💚 shadedclient 32m 2s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 21s the patch passed
+1 💚 compile 1m 14s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 1m 14s the patch passed
+1 💚 compile 1m 15s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 1m 15s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 14s the patch passed
+1 💚 mvnsite 1m 24s the patch passed
+1 💚 javadoc 0m 57s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 59s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 3m 47s the patch passed
+1 💚 shadedclient 30m 23s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 272m 28s hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 44s The patch does not generate ASF License warnings.
422m 18s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8320/1/artifact/out/Dockerfile
GITHUB PR #8320
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux b1a49cf9c1c7 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / a1cfee7
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8320/1/testReport/
Max. process+thread count 3732 (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-8320/1/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants