Skip to content

HDFS-17791: Fix libhdfs client that needlessly outputs full stack trace for common "file not found" errors #7696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

cvuosalo
Copy link

@cvuosalo cvuosalo commented May 19, 2025

This PR fixes issue HDFS-17791.

The libhdfs client outputs a full Java stack trace in its error message for a "file not found" error. Our HDFS application processes numerous queries checking for the presence of files, so "file not found" errors are frequent. Each such error generates a very lengthy and useless Java stack trace. These traces have no diagnostic value, since the cause of the error is that the file doesn't exist.

See the comment below for an example of the error with stack trace.

This PR eliminates the stack trace in the case of a "file not found" error. The stack trace will still be output for other kinds of errors.

How was this patch tested?

This patch was tested by loading it into our HDFS application and sending it queries for non-existent files. Concise and useful error messages resulted in the error log that no longer had the lengthy stack traces.

This patch only changes the libhdfs C API library.There's no change to HDFS itself. The effect of the change can only be seen in an application that uses libhdfs to open files.

@cvuosalo
Copy link
Author

Example of error message prior to this change. Part of the Java stack trace actually appears twice. A message like this appears in our logs for every "file not found" error.

File we will access: /store/mc/RunIIISummer24PrePremix/Neutrino_E-10_gun/PREMIX/Premixlib2024_140X_mcRun3_2024_realistic_v26-v1/2520137/a65fd95a-1302-4e95-98a0-e8d4ad856aab.root
hdfsOpenFile(/store/mc/RunIIISummer24PrePremix/Neutrino_E-10_gun/PREMIX/Premixlib2024_140X_mcRun3_2024_realistic_v26-v1/2520137/a65fd95a-1302-4e95-98a0-e8d4ad856aab.root): FileSystem#open((Lorg/apache/hadoop/fs/Path;I)Lorg/apache/hadoop/fs/FSDataInputStream;) error:
RemoteException: File does not exist: /store/mc/RunIIISummer24PrePremix/Neutrino_E-10_gun/PREMIX/Premixlib2024_140X_mcRun3_2024_realistic_v26-v1/2520137/a65fd95a-1302-4e95-98a0-e8d4ad856aab.root
  at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:86)
  at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:76)
  at org.apache.hadoop.hdfs.server.namenode.FSDirStatAndListingOp.getBlockLocations(FSDirStatAndListingOp.java:156)
  at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocations(FSNamesystem.java:2124)
  at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getBlockLocations(NameNodeRpcServer.java:770)
  at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getBlockLocations(ClientNamenodeProtocolServerSideTranslatorPB.java:460)
  at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:621)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:589)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:573)
  at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:1227)
  at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:1094)
  at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:1017)
  at java.base/java.security.AccessController.doPrivileged(Native Method)
  at java.base/javax.security.auth.Subject.doAs(Subject.java:423)
  at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899)
  at org.apache.hadoop.ipc.Server$Handler.run(Server.java:3048)
java.io.FileNotFoundException: File does not exist: /store/mc/RunIIISummer24PrePremix/Neutrino_E-10_gun/PREMIX/Premixlib2024_140X_mcRun3_2024_realistic_v26-v1/2520137/a65fd95a-1302-4e95-98a0-e8d4ad856aab.root
  at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:86)
  at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:76)
  at org.apache.hadoop.hdfs.server.namenode.FSDirStatAndListingOp.getBlockLocations(FSDirStatAndListingOp.java:156)
  at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocations(FSNamesystem.java:2124)
  at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getBlockLocations(NameNodeRpcServer.java:770)
  at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getBlockLocations(ClientNamenodeProtocolServerSideTranslatorPB.java:460)
  at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:621)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:589)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:573)
  at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:1227)
  at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:1094)
  at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:1017)
  at java.base/java.security.AccessController.doPrivileged(Native Method)
  at java.base/javax.security.auth.Subject.doAs(Subject.java:423)
  at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899)
  at org.apache.hadoop.ipc.Server$Handler.run(Server.java:3048)
  at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
  at org.apache.hadoop.ipc.RemoteException.instantiateException(RemoteException.java:121)
  at org.apache.hadoop.ipc.RemoteException.unwrapRemoteException(RemoteException.java:88)
  at org.apache.hadoop.hdfs.DFSClient.callGetBlockLocations(DFSClient.java:902)
  at org.apache.hadoop.hdfs.DFSClient.getLocatedBlocks(DFSClient.java:889)
  at org.apache.hadoop.hdfs.DFSClient.getLocatedBlocks(DFSClient.java:878)
  at org.apache.hadoop.hdfs.DFSClient.open(DFSClient.java:1046)
  at org.apache.hadoop.hdfs.DistributedFileSystem$4.doCall(DistributedFileSystem.java:343)
  at org.apache.hadoop.hdfs.DistributedFileSystem$4.doCall(DistributedFileSystem.java:339)
  at org.apache.hadoop.fs.FileSystemLinkResolver.resolve(FileSystemLinkResolver.java:81)
  at org.apache.hadoop.hdfs.DistributedFileSystem.open(DistributedFileSystem.java:356)
Caused by: org.apache.hadoop.ipc.RemoteException(java.io.FileNotFoundException): File does not exist: /store/mc/RunIIISummer24PrePremix/Neutrino_E-10_gun/PREMIX/Premixlib2024_140X_mcRun3_2024_realistic_v26-v1/2520137/a65fd95a-1302-4e95-98a0-e8d4ad856aab.root
  at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:86)
  at org.apache.hadoop.hdfs.server.namenode.INodeFile.valueOf(INodeFile.java:76)
  at org.apache.hadoop.hdfs.server.namenode.FSDirStatAndListingOp.getBlockLocations(FSDirStatAndListingOp.java:156)
  at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocations(FSNamesystem.java:2124)
  at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.getBlockLocations(NameNodeRpcServer.java:770)
  at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.getBlockLocations(ClientNamenodeProtocolServerSideTranslatorPB.java:460)
  at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:621)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:589)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine2.java:573)
  at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:1227)
  at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:1094)
  at org.apache.hadoop.ipc.Server$RpcCall.run(Server.java:1017)
  at java.base/java.security.AccessController.doPrivileged(Native Method)
  at java.base/javax.security.auth.Subject.doAs(Subject.java:423)
  at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899)
  at org.apache.hadoop.ipc.Server$Handler.run(Server.java:3048)

  at org.apache.hadoop.ipc.Client.getRpcResponse(Client.java:1567)
  at org.apache.hadoop.ipc.Client.call(Client.java:1513)
  at org.apache.hadoop.ipc.Client.call(Client.java:1410)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Invoker.invoke(ProtobufRpcEngine2.java:258)
  at org.apache.hadoop.ipc.ProtobufRpcEngine2$Invoker.invoke(ProtobufRpcEngine2.java:139)
  at com.sun.proxy.$Proxy12.getBlockLocations(Unknown Source)
  at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.getBlockLocations(ClientNamenodeProtocolTranslatorPB.java:334)
  at jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
  at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:433)
  at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeMethod(RetryInvocationHandler.java:166)
  at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invoke(RetryInvocationHandler.java:158)
  at org.apache.hadoop.io.retry.RetryInvocationHandler$Call.invokeOnce(RetryInvocationHandler.java:96)
  at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:362)
  at com.sun.proxy.$Proxy13.getBlockLocations(Unknown Source)
  at org.apache.hadoop.hdfs.DFSClient.callGetBlockLocations(DFSClient.java:900)
  ... 7 more

@cvuosalo
Copy link
Author

With this patch, the error message for a non-existent file is brief and clear:

File we will access: /store/user/cvuosalo/testfxile3.txt
hdfsOpenFile(/store/user/cvuosalo/testfxile3.txt): FileSystem#open((Lorg/apache/hadoop/fs/Path;I)Lorg/apache/hadoop/fs/FSDataInputStream;) error:
RemoteException: File does not exist: /store/user/cvuosalo/testfxile3.txt

@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 49m 33s 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 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 0m 25s /branch-mvninstall-root.txt root in trunk failed.
-1 ❌ compile 0m 23s /branch-compile-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in trunk failed.
-1 ❌ mvnsite 0m 24s /branch-mvnsite-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in trunk failed.
+1 💚 shadedclient 2m 18s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
-1 ❌ mvninstall 0m 40s /patch-mvninstall-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
-1 ❌ compile 0m 24s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
-1 ❌ cc 0m 24s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
-1 ❌ golang 0m 24s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
-1 ❌ javac 0m 24s /patch-compile-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
-1 ❌ blanks 0m 0s /blanks-tabs.txt The patch 10 line(s) with tabs.
-1 ❌ mvnsite 0m 24s /patch-mvnsite-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
+1 💚 shadedclient 1m 22s patch has no errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 0m 19s /patch-unit-hadoop-hdfs-project_hadoop-hdfs-native-client.txt hadoop-hdfs-native-client in the patch failed.
+0 🆗 asflicense 0m 25s ASF License check generated no output?
57m 19s
Subsystem Report/Notes
Docker ClientAPI=1.49 ServerAPI=1.49 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7696/1/artifact/out/Dockerfile
GITHUB PR #7696
Optional Tests dupname asflicense compile cc mvnsite javac unit codespell detsecrets golang
uname Linux 1389042e3288 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 28856a3
Default Java Red Hat, Inc.-1.8.0_412-b08
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7696/1/testReport/
Max. process+thread count 46 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs-native-client U: hadoop-hdfs-project/hadoop-hdfs-native-client
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7696/1/console
versions git=2.9.5 maven=3.6.3
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@cvuosalo cvuosalo changed the title HDFS: Fix libhdfs client that needlessly outputs full stack trace for common "file not found" errors HDFS-17791: Fix libhdfs client that needlessly outputs full stack trace for common "file not found" errors May 20, 2025
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 19m 16s 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 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 23m 36s /branch-mvninstall-root.txt root in trunk failed.
+1 💚 compile 1m 56s trunk passed
+1 💚 mvnsite 0m 21s trunk passed
+1 💚 shadedclient 45m 36s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 10s the patch passed
+1 💚 compile 1m 47s the patch passed
+1 💚 cc 1m 47s the patch passed
+1 💚 golang 1m 47s the patch passed
+1 💚 javac 1m 47s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 mvnsite 0m 12s the patch passed
+1 💚 shadedclient 19m 33s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 5m 53s hadoop-hdfs-native-client in the patch passed.
+1 💚 asflicense 0m 28s The patch does not generate ASF License warnings.
94m 23s
Subsystem Report/Notes
Docker ClientAPI=1.49 ServerAPI=1.49 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7696/2/artifact/out/Dockerfile
GITHUB PR #7696
Optional Tests dupname asflicense compile cc mvnsite javac unit codespell detsecrets golang
uname Linux 6bea57b0acb9 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 71dfe64
Default Java Red Hat, Inc.-1.8.0_412-b08
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7696/2/testReport/
Max. process+thread count 554 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs-native-client U: hadoop-hdfs-project/hadoop-hdfs-native-client
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-7696/2/console
versions git=2.9.5 maven=3.6.3
Powered by Apache Yetus 0.14.0 https://yetus.apache.org

This message was automatically generated.

@cvuosalo cvuosalo marked this pull request as ready for review May 20, 2025 21:48
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.

2 participants