{"record":{"id":"fee9499a0d749367","repo":"apache/hadoop","slug":"path-strb-already-exists-as-dir-cannot-create-l","errorCode":null,"errorMessage":"Path {strB} already exists as dir; cannot create link here","messagePattern":"Path (.+?) already exists as dir; cannot create link here","errorType":"validation","errorClass":"FileAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java","lineNumber":476,"sourceCode":"          throw new FileAlreadyExistsException(\"Path \" + nextInode.fullPath +\n              \" already exists as link\");\n        }\n      } else {\n        assert(nextInode.isInternalDir());\n        curInode = (INodeDir<T>) nextInode;\n      }\n    }\n\n    // Now process the last component\n    // Add the link in 2 cases: does not exist or a link exists\n    String iPath = srcPaths[i];// last component\n    if (curInode.resolveInternal(iPath) != null) {\n      //  directory/link already exists\n      StringBuilder strB = new StringBuilder(srcPaths[0]);\n      for (int j = 1; j <= i; ++j) {\n        strB.append('/').append(srcPaths[j]);\n      }\n      throw new FileAlreadyExistsException(\"Path \" + strB +\n          \" already exists as dir; cannot create link here\");\n    }\n\n    final INodeLink<T> newLink;\n    final String fullPath = curInode.fullPath + (curInode == root ? \"\" : \"/\")\n        + iPath;\n    switch (linkType) {\n    case SINGLE:\n      newLink = new INodeLink<T>(fullPath, aUgi,\n          initAndGetTargetFs(), target);\n      break;\n    case SINGLE_FALLBACK:\n    case MERGE_SLASH:\n      // Link fallback and link merge slash configuration\n      // are handled specially at InodeTree.\n      throw new IllegalArgumentException(\"Unexpected linkType: \" + linkType);\n    case MERGE:\n    case NFLY:","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/InodeTree.java#L458-L494","documentation":"When the last component of a new link's source path already exists in the inode tree (typically an internal directory created earlier by a deeper mount), InodeTree throws FileAlreadyExistsException('Path <path> already exists as dir; cannot create link here'). A directory and a link cannot occupy the same mount point.","triggerScenarios":"Mount entries that first create internal directories (e.g. link./a/b) and then try to link at the same position (e.g. link./a); duplicate link, fallback or nfly entries for the same source path.","commonSituations":"Appending a root-level link after deeper mounts exist; configuration assembled from multiple files (core-site.xml plus an included file) that both claim the same path.","solutions":["Delete the duplicate or conflicting entry so each source path is claimed exactly once","Order and deduplicate mount keys when generating configuration","Search every active config source for the offending fs.viewfs.mounttable keys"],"exampleFix":"<!-- before: /a/b mounted, then /a linked at the occupied dir -->\n<property><name>fs.viewfs.mounttable.cluster.link./a/b</name>\n  <value>hdfs://nnB/b</value></property>\n<property><name>fs.viewfs.mounttable.cluster.link./a</name>\n  <value>hdfs://nnA/a</value></property>\n\n<!-- after: one owner for /a -->\n<property><name>fs.viewfs.mounttable.cluster.link./a/b</name>\n  <value>hdfs://nnB/b</value></property>","handlingStrategy":"try-catch","validationCode":"static boolean hasDuplicateMountSources(Collection<String> srcs) {\n  return new HashSet<>(srcs).size() != srcs.size();\n}","typeGuard":null,"tryCatchPattern":"Catch FileAlreadyExistsException at ViewFileSystem init; 'already exists as dir; cannot create link here' means a link and a directory claim the same path — locate both fs.viewfs.mounttable entries across all config files and keep one.","preventionTips":["Claim each mount path exactly once","Audit included config files for overlapping viewfs keys","Validate generated mount tables with a duplicate/overlap check"],"tags":["hadoop","viewfs","mount-table","configuration","conflict"],"backgroundTag":"mount-point-conflict","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}