apache/hadoop · error · UnsupportedOperationException

{} doesn't support deleteSnapshot

Error message

{} doesn't support deleteSnapshot

What it means

FileSystem.deleteSnapshot(Path, String) is optional; the base class throws UnsupportedOperationException with getClass().getSimpleName() + " doesn't support deleteSnapshot". Only HDFS snapshot-capable clients (DistributedFileSystem, WebHdfsFileSystem, plus view/chroot/filter pass-throughs) implement it; everything else — including LocalFileSystem and object stores — throws.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:3132

   *         (default outcome).
   */
  public void renameSnapshot(Path path, String snapshotOldName,
      String snapshotNewName) throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support renameSnapshot");
  }

  /**
   * Delete a snapshot of a directory.
   * @param path  The directory that the to-be-deleted snapshot belongs to
   * @param snapshotName The name of the snapshot
   * @throws IOException IO failure
   * @throws UnsupportedOperationException if the operation is unsupported
   *         (default outcome).
   */
  public void deleteSnapshot(Path path, String snapshotName)
      throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()
        + " doesn't support deleteSnapshot");
  }

  /**
   * Modifies ACL entries of files and directories.  This method can add new ACL
   * entries or modify the permissions on existing ACL entries.  All existing
   * ACL entries that are not specified in this call are retained without
   * changes.  (Modifications are merged into the current ACL.)
   *
   * @param path Path to modify
   * @param aclSpec List<AclEntry> describing modifications
   * @throws IOException if an ACL could not be modified
   * @throws UnsupportedOperationException if the operation is unsupported
   *         (default outcome).
   */
  public void modifyAclEntries(Path path, List<AclEntry> aclSpec)
      throws IOException {
    throw new UnsupportedOperationException(getClass().getSimpleName()

View on GitHub (pinned to 2add963021)

Solutions

  1. Probe fs.hasPathCapability(dir, CommonPathCapabilities.FS_SNAPSHOTS) before calling
  2. Run retention tooling only against the hdfs:// namespace (explicit scheme in the path avoids fs.defaultFS mistakes)
  3. Catch UnsupportedOperationException and treat 'no snapshot support' as 'nothing to prune'
  4. For object stores, implement retention over store-native versions or manifest-based backups

Example fix

// before
fs.deleteSnapshot(dir, snapshotName); // throws on LocalFileSystem/S3A

// after
if (fs.hasPathCapability(dir, CommonPathCapabilities.FS_SNAPSHOTS)) {
  fs.deleteSnapshot(dir, snapshotName);
} else {
  LOG.debug("{} has no snapshot support; skip prune", fs.getUri());
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (fs.hasPathCapability(dir, CommonPathCapabilities.FS_SNAPSHOTS)) {
  fs.deleteSnapshot(dir, snapshotName);
}

Type guard

static boolean supportsSnapshotDelete(FileSystem fs) {
  return fs instanceof DistributedFileSystem;
}

Try / catch

try {
  fs.deleteSnapshot(dir, name);
} catch (UnsupportedOperationException e) {
  // store cannot have snapshots: nothing to delete, continue retention loop
}

Prevention

When it happens

Trigger: Calling fs.deleteSnapshot(dir, name) on file://, s3a://, abfs://, gs://, har:// or an unmodified custom FileSystem; retention/cleanup jobs that prune old snapshots run against the wrong scheme.

Common situations: Snapshot-retention cron jobs reused across environments; unit tests of backup tooling against RawLocalFileSystem; ViewFileSystem mounts backed by non-HDFS stores.

Related errors


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