Skip to content

HDFS-17630. Avoid PacketReceiver#MAX_PACKET_SIZE Initialized to 0.#8329

Open
balodesecurity wants to merge 2 commits intoapache:trunkfrom
balodesecurity:HDFS-17630
Open

HDFS-17630. Avoid PacketReceiver#MAX_PACKET_SIZE Initialized to 0.#8329
balodesecurity wants to merge 2 commits intoapache:trunkfrom
balodesecurity:HDFS-17630

Conversation

@balodesecurity
Copy link

Summary

  • PacketReceiver.MAX_PACKET_SIZE was set via a static { new HdfsConfiguration(); ... } initializer. When config resources are loaded from HDFS URLs (e.g., during JAR loading via URLJarFile), the resulting class-loading chain can instantiate BlockReaderRemote before PacketReceiver finishes initializing. The JVM then returns the partially-initialized class with MAX_PACKET_SIZE == 0, causing every subsequent block read to throw IOException: Incorrect value for packet payload size.
  • Fix: initialize MAX_PACKET_SIZE directly to the compile-time default constant (eliminating the static initializer) and add a static setMaxPacketSize(Configuration) method that DFSClient calls during construction to apply any operator-configured override. This breaks the circular class-loading dependency while preserving configurability.

Test plan

  • New tests TestPacketReceiver#testMaxPacketSizeDefaultIsNonZero and TestPacketReceiver#testSetMaxPacketSizeFromConfig pass
  • All existing TestPacketReceiver tests continue to pass

The previous static initializer in PacketReceiver called
new HdfsConfiguration(), which loads config resources via URL connections.
If those URLs pointed to HDFS, the resulting class-loading chain could
instantiate BlockReaderRemote before PacketReceiver finished initializing,
causing the JVM to return the partially-initialized class with
MAX_PACKET_SIZE == 0. Any subsequent block read then failed with
"Incorrect value for packet payload size".

Fix: initialize MAX_PACKET_SIZE directly to the compile-time default
constant (removing the static initializer entirely) and introduce a
static setMaxPacketSize(Configuration) method that DFSClient calls
during construction to apply any configured override. This eliminates
the circular class-loading dependency while preserving configurability.

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

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 2m 30s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s 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 _
+0 🆗 mvndep 1m 50s Maven dependency ordering for branch
+1 💚 mvninstall 51m 17s trunk passed
+1 💚 compile 5m 57s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 6m 22s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 2m 12s trunk passed
+1 💚 mvnsite 3m 17s trunk passed
+1 💚 javadoc 2m 32s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 2m 32s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 8m 14s trunk passed
+1 💚 shadedclient 38m 5s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+0 🆗 mvndep 0m 29s Maven dependency ordering for patch
+1 💚 mvninstall 2m 16s the patch passed
+1 💚 compile 5m 22s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 5m 22s the patch passed
+1 💚 compile 6m 1s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 6m 1s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 1m 44s /results-checkstyle-hadoop-hdfs-project.txt hadoop-hdfs-project: The patch generated 2 new + 45 unchanged - 0 fixed = 47 total (was 45)
+1 💚 mvnsite 2m 24s the patch passed
+1 💚 javadoc 1m 38s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 1m 41s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 7m 41s the patch passed
+1 💚 shadedclient 36m 34s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 2m 36s hadoop-hdfs-client in the patch passed.
+1 💚 unit 262m 22s hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 49s The patch does not generate ASF License warnings.
455m 2s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8329/2/artifact/out/Dockerfile
GITHUB PR #8329
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux f63e75578216 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 / c58a264
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-8329/2/testReport/
Max. process+thread count 2393 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs-client hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8329/2/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