apache/hadoop · error · UnsupportedOperationException

{} doesn't support deleteSnapshot

Error message

{} doesn't support deleteSnapshot

What it means

AbstractFileSystem.deleteSnapshot(Path, String) is a default stub that unconditionally throws UnsupportedOperationException prefixed with the subclass name. Deleting snapshots is HDFS-only functionality; the stub fires for every filesystem that does not override it. The error is about missing feature support, not about a missing snapshot.

Source

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

   * @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");
  }

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

  /**
   * Set the source path to satisfy storage policy.
   * @param path The source path referring to either a directory or a file.
   * @throws IOException raised on errors performing I/O.
   */
  public void satisfyStoragePolicy(final Path path) throws IOException {
    throw new UnsupportedOperationException(
        getClass().getSimpleName() + " doesn't support satisfyStoragePolicy");
  }

  /**
   * Set the storage policy for a given file or directory.
   *
   * @param path file or directory path.
   * @param policyName the name of the target storage policy. The list

View on GitHub (pinned to 2add963021)

Solutions

  1. Run deleteSnapshot only against hdfs:// paths.
  2. Use DistributedFileSystem.deleteSnapshot / `hdfs dfs -deleteSnapshot` for the HDFS contract.
  3. Filter paths by URI scheme before invoking snapshot APIs.
  4. Catch UnsupportedOperationException and treat deletion as done/skipped when snapshots cannot exist.

Example fix

// before
fc.deleteSnapshot(dir, "expired-7"); // throws on s3a://

// after
if ("hdfs".equals(dir.toUri().getScheme())) {
  fc.deleteSnapshot(dir, "expired-7");
}
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.deleteSnapshot(dir, name);
} catch (UnsupportedOperationException e) {
  // no snapshot store: deletion is a no-op
}

Prevention

When it happens

Trigger: FileContext.deleteSnapshot(snapshotDir, name) on local or object-store schemes; cleanup jobs deleting expired snapshots after the mount table or defaultFS changed; snapshot retention tooling run generically over mixed-scheme paths.

Common situations: Retention/expiry scripts written for HDFS clusters are reused on environments whose storage is s3a/gs/local; viewfs mount entries pointing at non-HDFS stores; test harnesses with file:// defaultFS exercising the same code path.

Related errors


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