{"record":{"id":"245ad77c14e7394d","repo":"apache/hadoop","slug":"file-directory-iip-getpath-does-not-exi","errorCode":null,"errorMessage":"\"File/Directory \" + iip.getPath() + \" does not exist.\"","messagePattern":"\"File/Directory \" \\+ iip\\.getPath\\(\\) \\+ \" does not exist\\.\"","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java","lineNumber":500,"sourceCode":"      List<XAttr> removed = Lists.newArrayList();\n      newXAttrs = FSDirXAttrOp.filterINodeXAttrs(existingXAttrs, toRemove,\n          removed);\n    } else {\n      newXAttrs = FSDirXAttrOp.setINodeXAttrs(fsd, existingXAttrs,\n          Arrays.asList(xAttr),\n          EnumSet.of(XAttrSetFlag.CREATE, XAttrSetFlag.REPLACE));\n    }\n    XAttrStorage.updateINodeXAttrs(inode, newXAttrs, iip.getLatestSnapshotId());\n  }\n\n  static boolean unprotectedSetTimes(\n      FSDirectory fsd, INodesInPath iip, long mtime, long atime, boolean force)\n      throws FileNotFoundException {\n    assert fsd.hasWriteLock();\n    boolean status = false;\n    INode inode = iip.getLastINode();\n    if (inode == null) {\n      throw new FileNotFoundException(\"File/Directory \" + iip.getPath() +\n          \" does not exist.\");\n    }\n    int latest = iip.getLatestSnapshotId();\n    if (mtime >= 0) {\n      inode = inode.setModificationTime(mtime, latest);\n      status = true;\n    }\n\n    // if the last access time update was within the last precision interval,\n    // then no need to store access time\n    if (atime >= 0 && (status || force\n        || atime > inode.getAccessTime() + fsd.getAccessTimePrecision())) {\n      inode.setAccessTime(atime, latest,\n          fsd.getFSNamesystem().getSnapshotManager().\n          getSkipCaptureAccessTimeOnlyChange());\n      status = true;\n    }\n    return status;","sourceCodeStart":482,"sourceCodeEnd":518,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirAttrOp.java#L482-L518","documentation":"Thrown by the NameNode while processing setTimes (ClientProtocol.setTimes) when the resolved path's last component has no inode, i.e. the file or directory does not exist in the namespace. unprotectedSetTimes resolves the path with INodesInPath and treats a null last inode as a hard failure. Because resolution and the metadata update happen under the write lock, in practice this almost always means the path was deleted or renamed before the RPC landed, or the client is using a stale path.","triggerScenarios":"Calling DistributedFileSystem.setTimes(path, mtime, atime) (or any API that funnels into FSDirAttrOp.setTimes, e.g. distcp preserving times) on a path that (a) never existed due to a typo, (b) was deleted between the client's listing and the setTimes call, or (c) was renamed concurrently.","commonSituations":"Distcp or archive jobs copying metadata for files that another process is deleting; retrying operations against a path after a failover where the edit was lost; tools that cache FileStatus objects and later call setTimes on them.","solutions":["Verify the path exists immediately before the call with fs.getFileStatus(path) and treat a FileNotFoundException from that check as 'skip'.","If a concurrent delete is expected, catch FileNotFoundException around setTimes and re-check existence to distinguish 'deleted meanwhile' (ignore) from a real bug (fix the path).","Audit the code path that produced the path string — usually a stale listing, a wrong base directory, or a path built for the wrong cluster/namespace.","For distcp-like metadata sync, snapshot or lock the source set so delete/rename cannot interleave with setTimes."],"exampleFix":"// before\nfs.setTimes(path, mtime, atime);\n\n// after\ntry {\n  fs.setTimes(path, mtime, atime);\n} catch (FileNotFoundException e) {\n  // removed by a concurrent delete/rename; verify and skip\n  if (!fs.exists(path)) {\n    LOG.debug(\"Skipping setTimes, path deleted concurrently: {}\", path);\n  } else {\n    throw e;\n  }\n}","handlingStrategy":"try-catch","validationCode":"// shrink the race window; does not eliminate it\nif (!fs.exists(path)) {\n  return; // nothing to update\n}","typeGuard":null,"tryCatchPattern":"try {\n  fs.setTimes(path, mtime, atime);\n} catch (FileNotFoundException e) {\n  // deleted/renamed concurrently: confirm and skip\n  if (!fs.exists(path)) { LOG.debug(\"setTimes skipped, path gone: {}\", path); }\n  else { throw e; }\n}","preventionTips":["Do not cache paths or FileStatus across long-running jobs that run concurrent deletes; re-list before metadata updates.","In distcp-style metadata sync, snapshot the source set or accept FileNotFoundException as an expected outcome and count it.","Treat FileNotFoundException from setTimes as a signal to refresh the parent listing, not as a fatal error."],"tags":["hdfs","namenode","settimes","file-not-found","concurrent-delete"],"backgroundTag":"file-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}