{"record":{"id":"918ef75beb21f2c6","repo":"apache/hadoop","slug":"can-t-get-path-for-handle-path","errorCode":null,"errorMessage":"Can't get path for handle path: {}","messagePattern":"Can't get path for handle path: (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java","lineNumber":1619,"sourceCode":"              \"mismatches.\");\n        } else {\n          LOG.error(\"CookieVerf mismatch. request cookieVerf: {} \" +\n              \"dir cookieVerf: {}\",\n              cookieVerf, dirStatus.getModificationTime());\n          return new READDIR3Response(\n              Nfs3Status.NFS3ERR_BAD_COOKIE,\n              Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug));\n        }\n      }\n\n      if (cookie == 0) {\n        // Get dotdot fileId\n        String dotdotFileIdPath = dirFileIdPath + \"/..\";\n        HdfsFileStatus dotdotStatus = dfsClient.getFileInfo(dotdotFileIdPath);\n\n        if (dotdotStatus == null) {\n          // This should not happen\n          throw new IOException(\"Can't get path for handle path: \"\n              + dotdotFileIdPath);\n        }\n        dotdotFileId = dotdotStatus.getFileId();\n      }\n\n      // Get the list from the resume point\n      byte[] startAfter;\n      if(cookie == 0 ) {\n        startAfter = HdfsFileStatus.EMPTY_NAME;\n      } else {\n        String inodeIdPath = Nfs3Utils.getFileIdPath(cookie);\n        startAfter = inodeIdPath.getBytes(StandardCharsets.UTF_8);\n      }\n\n      dlisting = listPaths(dfsClient, dirFileIdPath, startAfter);\n      postOpAttr = Nfs3Utils.getFileAttr(dfsClient, dirFileIdPath, iug);\n      if (postOpAttr == null) {\n        LOG.error(\"Can't get path for fileId: {}\", handle.getFileId());","sourceCodeStart":1601,"sourceCodeEnd":1637,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-nfs/src/main/java/org/apache/hadoop/hdfs/nfs/nfs3/RpcProgramNfs3.java#L1601-L1637","documentation":"Thrown by RpcProgramNfs3.readdir() while servicing an NFS3 READDIR request with cookie == 0: the gateway resolves the parent entry ('..') of the directory being listed via dfsClient.getFileInfo(dirFileIdPath + \"/..\") to compute dotdotFileId, and getFileInfo returns null. The source marks it 'This should not happen' — it means the gateway's HDFS client could not resolve an inode-by-id path that ought to exist, so the IOException escapes the handler as an IO error back to the NFS client.","triggerScenarios":"An NFS client starts a fresh listing (cookie 0) of a directory handle; concurrently the directory (or an ancestor) is deleted or renamed in HDFS so the '..' inode-by-id path no longer resolves, or the gateway's DFSClient is unhealthy (lost NameNode connection after failover/upgrade) and getFileInfo returns null for an otherwise valid path.","commonSituations":"Cleanup or compaction jobs deleting directories while an NFS-mounted client (ls, rsync, backup) is listing them; the NFS gateway surviving an HDFS restart/failover with a stale DFSClient; heavy rename churn under the listed path.","solutions":["Retry the listing from the NFS client — if the directory was removed the handle is ESTALE and a re-lookup of the path is the correct behavior","Verify the directory still exists: hdfs dfs -ls <path>, and check whether another job deleted/renamed it mid-listing","Check the NFS gateway log and its NameNode connectivity (failed RPCs make getFileInfo return null for valid paths)","Restart the NFS gateway if its DFSClient is wedged after an HDFS restart, HA failover, or upgrade"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// In NFS3 handler wrappers: convert listing failures into NFS-level errors, not dropped RPCs\ntry {\n  response = readdir(xdr, securityHandler, client);\n} catch (IOException e) {\n  LOG.warn(\"READDIR failed for handle: {}\", handle, e);\n  return new READDIR3Response(Nfs3Status.NFS3ERR_IO); // client retries / re-lookups\n}","preventionTips":["Treat ESTALE-style failures as expected: NFS clients should re-lookup paths when a listed directory disappears","Keep the gateway on a healthy HDFS client — monitor NN RPC health and restart the gateway after HDFS failover/upgrade","Avoid deleting directories that NFS clients actively list; use rename-then-delete during churn","Run listings with retries in scripts (ls may fail transiently mid-churn)"],"tags":["hadoop","hdfs","nfs","readdir","stale-handle","concurrency"],"backgroundTag":"stale-file-handle","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}