apache/hadoop · error · FileNotFoundException

rename destination parent {} not found.

Error message

rename destination parent {} not found.

What it means

FileNotFoundException when the destination's parent directory does not exist - HDFS rename never creates missing parents, so the new name must live inside an existing directory. It fires when dstIIP's second-to-last inode is null, after src/dst validation succeeded.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirRenameOp.java:424

          error);
      throw new IOException(error);
    }

    BlockStoragePolicySuite bsps = fsd.getBlockStoragePolicySuite();
    fsd.ezManager.checkMoveValidity(srcIIP, dstIIP);
    final INode dstInode = dstIIP.getLastINode();
    List<INodeDirectory> dstSnapshottableDirs = new ArrayList<>();
    if (dstInode != null) { // Destination exists
      validateOverwrite(src, dst, overwrite, srcInode, dstInode);
      FSDirSnapshotOp.checkSnapshot(fsd, dstIIP, dstSnapshottableDirs);
    }

    INode dstParent = dstIIP.getINode(-2);
    if (dstParent == null) {
      error = "rename destination parent " + dst + " not found.";
      NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: " +
          error);
      throw new FileNotFoundException(error);
    }
    if (!dstParent.isDirectory()) {
      error = "rename destination parent " + dst + " is a file.";
      NameNode.stateChangeLog.warn("DIR* FSDirectory.unprotectedRenameTo: " +
          error);
      throw new ParentNotDirectoryException(error);
    }

    validateNestSnapshot(fsd, src,
            dstParent.asDirectory(), srcSnapshottableDirs);
    checkUnderSameSnapshottableRoot(fsd, srcIIP, dstIIP);

    // Ensure dst has quota to accommodate rename
    verifyFsLimitsForRename(fsd, srcIIP, dstIIP);
    Pair<Optional<QuotaCounts>, Optional<QuotaCounts>> quotaPair =
        verifyQuotaForRename(fsd, srcIIP, dstIIP);

    RenameOperation tx = new RenameOperation(fsd, srcIIP, dstIIP, quotaPair);

View on GitHub (pinned to 2add963021)

Solutions

  1. Create the parent first: `hdfs dfs -mkdir -p <dstParent>` then retry the rename.
  2. Fix step ordering in the job so directory creation precedes the move.
  3. In code, pre-check fs.exists(dst.getParent()) and mkdirs it when absent.

Example fix

// before
fs.rename(new Path("/staging/part"), new Path("/out/2026/08/22/part")); // parent /out/2026 missing

// after
Path dst = new Path("/out/2026/08/22/part");
if (!fs.exists(dst.getParent())) fs.mkdirs(dst.getParent());
fs.rename(new Path("/staging/part"), dst);
Defensive patterns

Strategy: validation

Validate before calling

Path parent = dst.getParent();
if (!fs.exists(parent) && !fs.mkdirs(parent)) {
  throw new IOException("Could not create destination parent " + parent);
}
fs.rename(src, dst);

Try / catch

try {
  fs.rename(src, dst);
} catch (FileNotFoundException e) {
  if (!fs.exists(dst.getParent())) {
    fs.mkdirs(dst.getParent());
    fs.rename(src, dst);
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: `hdfs dfs -mv /src /newdir/dst` where /newdir does not exist; renaming into a date-partitioned directory the job forgot to create; dst parent deleted concurrently between resolution and validation.

Common situations: Pipeline steps that mkdir output partitions only on success paths; ordering bugs where the move runs before the mkdir; destination paths built with a date string that skips a level.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/a92298d6a104b4d6. Report an issue: GitHub.