apache/hadoop · error · UnsupportedOperationException

Cannot perform snapshot operations on a symlink to a non-Dis

Error message

Cannot perform snapshot operations on a symlink to a non-DistributedFileSystem: 

What it means

allowSnapshot(Path) resolves symlinks via FileSystemLinkResolver; snapshots are an HDFS-only feature, so when the resolved target filesystem is not a DistributedFileSystem the next() callback throws UnsupportedOperationException. The message shows the original path and the resolved target path.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java:2252

  public void allowSnapshot(final Path path) throws IOException {
    statistics.incrementWriteOps(1);
    storageStatistics.incrementOpCounter(OpType.ALLOW_SNAPSHOT);
    Path absF = fixRelativePart(path);
    new FileSystemLinkResolver<Void>() {
      @Override
      public Void doCall(final Path p) throws IOException {
        dfs.allowSnapshot(getPathName(p));
        return null;
      }

      @Override
      public Void next(final FileSystem fs, final Path p)
          throws IOException {
        if (fs instanceof DistributedFileSystem) {
          DistributedFileSystem myDfs = (DistributedFileSystem)fs;
          myDfs.allowSnapshot(p);
        } else {
          throw new UnsupportedOperationException("Cannot perform snapshot"
              + " operations on a symlink to a non-DistributedFileSystem: "
              + path + " -> " + p);
        }
        return null;
      }
    }.resolve(this, absF);
  }

  /** @see org.apache.hadoop.hdfs.client.HdfsAdmin#disallowSnapshot(Path) */
  public void disallowSnapshot(final Path path) throws IOException {
    statistics.incrementWriteOps(1);
    storageStatistics.incrementOpCounter(OpType.DISALLOW_SNAPSHOT);
    Path absF = fixRelativePart(path);
    new FileSystemLinkResolver<Void>() {
      @Override
      public Void doCall(final Path p) throws IOException {
        checkTrashRootAndRemoveIfEmpty(p);
        dfs.disallowSnapshot(getPathName(p));

View on GitHub (pinned to 2add963021)

Solutions

  1. Check FileContext/FileSystem of the resolved target: only call allowSnapshot when the path resolves on the same DistributedFileSystem (e.g., compare fs.getUri() with the qualified target's URI).
  2. Remove cross-filesystem symlinks from trees managed with HDFS snapshots.
  3. Call allowSnapshot on the real HDFS path (resolve the link first) using the DistributedFileSystem instance for that URI.
  4. Skip non-HDFS paths in bulk snapshot-enablement jobs.

Example fix

// before
hdfs.allowSnapshot(path); // throws if path is a cross-filesystem symlink

// after
Path resolved = path;
FileStatus st = hdfs.getFileLinkStatus(path);
if (st.isSymlink()) resolved = hdfs.resolvePath(path);
if (resolved.toUri().getScheme().equals(hdfs.getUri().getScheme())) {
  hdfs.allowSnapshot(resolved);
} else {
  LOG.warn("Skipping non-HDFS path for snapshot: {}", resolved);
}
Defensive patterns

Strategy: validation

Validate before calling

Path resolved = fs.getFileStatus(path).getPath();
URI t = resolved.toUri();
boolean sameCluster = "hdfs".equals(t.getScheme())
    && hdfs.getUri().getAuthority().equals(t.getAuthority());
if (sameCluster) hdfs.allowSnapshot(resolved);

Try / catch

try {
  hdfs.allowSnapshot(path);
} catch (UnsupportedOperationException e) {
  // path resolved off-cluster: skip and log
}

Prevention

When it happens

Trigger: Calling hdfs.allowSnapshot(p) where p is an HDFS symlink pointing to a path on another filesystem (file://, s3a://, webhdfs mounted under a different FileSystem instance, etc.).

Common situations: Snapshot-setup automation walking directory trees that contain cross-scheme symlinks; backup scripts enabling snapshots on config-derived paths where a mount now resolves elsewhere; viewfs mount layers routing to non-DFS backends.

Related errors


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