apache/hadoop · error · UnsupportedOperationException

{} doesn't support createSnapshot

Error message

{} doesn't support createSnapshot

What it means

Snapshots are an HDFS-only feature; AbstractFileSystem.createSnapshot(Path, String) is a default stub that throws UnsupportedOperationException naming the subclass. The method is only overridden by HDFS-backed implementations (Hdfs, WebHDFS, and viewfs mount entries that delegate to them). Seeing this error means you asked a non-HDFS filesystem to create a snapshot.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/AbstractFileSystem.java:1482

   * @throws IOException raised on errors performing I/O.
   */
  public void removeXAttr(Path path, String name) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support removeXAttr");
  }

  /**
   * The specification of this method matches that of
   * {@link FileContext#createSnapshot(Path, String)}.
   *
   * @param path the path.
   * @param snapshotName snapshot name.
   * @throws IOException raised on errors performing I/O.
   * @return path.
   */
  public Path createSnapshot(final Path path, final String snapshotName)
      throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support createSnapshot");
  }

  /**
   * The specification of this method matches that of
   * {@link FileContext#renameSnapshot(Path, String, String)}.
   *
   * @param path the path.
   * @param snapshotOldName snapshot old name.
   * @param snapshotNewName snapshot new name.
   * @throws IOException raised on errors performing I/O.
   */
  public void renameSnapshot(final Path path, final String snapshotOldName,
      final String snapshotNewName) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support renameSnapshot");
  }

View on GitHub (pinned to 2add963021)

Solutions

  1. Confirm the target path is hdfs:// (or webhdfs://) and that the mounted AbstractFileSystem is HDFS-backed; use that path for snapshot calls.
  2. Prefer the HDFS-specific API surface (DistributedFileSystem.createSnapshot / HdfsAdmin) which makes the HDFS requirement explicit.
  3. On HDFS, enable snapshots first with `hdfs dfsadmin -allowSnapshot <dir>` (that avoids the follow-on SnapshotException).
  4. Catch UnsupportedOperationException and skip snapshotting when the filesystem does not support it.

Example fix

// before
Path snap = fc.createSnapshot(dir, "daily-1"); // throws on file:// or s3a://

// after
if ("hdfs".equals(dir.toUri().getScheme())) {
  Path snap = fc.createSnapshot(dir, "daily-1");
} else {
  LOG.warn("Snapshots unsupported on {}", dir.toUri().getScheme());
}
Defensive patterns

Strategy: validation

Validate before calling

static boolean isSnapshotCapable(Path p) {
  String scheme = p.toUri().getScheme();
  return "hdfs".equals(scheme) || "webhdfs".equals(scheme);
}

Try / catch

try {
  fc.createSnapshot(dir, name);
} catch (UnsupportedOperationException e) {
  LOG.warn("snapshots unsupported on {}: skipping", dir);
}

Prevention

When it happens

Trigger: FileContext.createSnapshot(path, name) on local, object-store, or ftp schemes; a viewfs (mount-table) path whose target resolves to a non-HDFS store; snapshot-based backup tooling written against FileContext run with the wrong defaultFS.

Common situations: Portable backup/rollback scripts assume snapshots everywhere; a job configured with fs.defaultFS=file:/// in tests or a cluster migration repoints snapshot calls at unsupported stores. Note that even on HDFS the directory must first allow snapshots (a different error - SnapshotException - if not enabled).

Related errors


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