apache/hadoop · error · AccessControlException

Router federation rename can't rename snapshot path. src={}(

Error message

Router federation rename can't rename snapshot path. src={}({})

What it means

Router federation rename refuses to operate on snapshot paths: RouterFederationRename.checkSnapshotPath rejects any src whose remote destination path contains '/.snapshot/' (HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR + Path.SEPARATOR). Distcp-based fed rename cannot faithfully move snapshot metadata, so the operation is blocked up front with an AccessControlException.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/java/org/apache/hadoop/hdfs/server/federation/router/RouterFederationRename.java:192

  }

  private void checkRenamePermission(RemoteLocation srcLoc,
      RemoteLocation dstLoc) throws IOException {
    // check src path permission.
    Path srcPath =
        new Path("hdfs://" + srcLoc.getNameserviceId() + srcLoc.getDest());
    srcPath.getFileSystem(conf).access(srcPath.getParent(), FsAction.WRITE);
    // check dst path permission.
    Path dstPath =
        new Path("hdfs://" + dstLoc.getNameserviceId() + dstLoc.getDest());
    dstPath.getFileSystem(conf).access(dstPath.getParent(), FsAction.WRITE);
  }

  static void checkSnapshotPath(RemoteLocation src, RemoteLocation dst)
      throws AccessControlException {
    if (src.getDest()
        .contains(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR + Path.SEPARATOR)) {
      throw new AccessControlException(
          "Router federation rename can't rename snapshot path. src=" + src
              .getSrc() + "(" + src + ")");
    }
    if (dst.getDest()
        .contains(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR + Path.SEPARATOR)) {
      throw new AccessControlException(
          "Router federation rename can't rename snapshot path. dst=" + dst
              .getSrc() + "(" + dst + ")");
    }
  }

  /**
   * Build router federation rename job moving data from src to dst.
   * @param srcNs the source namespace id.
   * @param dstNs the dst namespace id.
   * @param src the source path.
   * @param dst the dst path.
   */

View on GitHub (pinned to 2add963021)

Solutions

  1. Rename the live (non-snapshot) path instead: address the source directory itself, not /path/.snapshot/<snap>/...
  2. If snapshot data must be preserved across namespaces, use distcp -snapshotDiff or copy the needed snapshot content explicitly to the target cluster
  3. Delete stale snapshots if the .snapshot reference is accidental, then retry the plain rename

Example fix

# before
hdfs dfs -fs hdfs://router -mv /src/.snapshot/snap1/data /dstmount/data
# after (rename the live path; snapshot content is copied separately if needed)
hdfs dfs -fs hdfs://router -mv /src/data /dstmount/data
Defensive patterns

Strategy: validation

Validate before calling

// Mirror the router check before issuing the rename
if (src.contains(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR + Path.SEPARATOR)) {
  throw new IllegalArgumentException("Fed rename cannot use snapshot src path: " + src);
}

Type guard

boolean isSnapshotPath(String path) {
  return path != null && path.contains("/.snapshot/");
}

Try / catch

try {
  dfs.rename(src, dst);
} catch (AccessControlException ace) {
  if (ace.getMessage() != null && ace.getMessage().contains("can't rename snapshot path. src=")) {
    // reissue against the live path instead of /path/.snapshot/snap/...
  }
  throw ace;
}

Prevention

When it happens

Trigger: rename(src, dst) across namespaces where the resolved src RemoteLocation destination contains a /.snapshot/ segment, e.g. renaming /mount/.snapshot/snap1/dir or any path addressing an element inside a snapshot.

Common situations: Users or tooling that references snapshot-relative paths (backup jobs, snapshot diff tooling) attempt a cross-mount rename; shell completion or scripts accidentally pin a .snapshot path as the source.

Related errors


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