apache/hadoop · error · UnsupportedOperationException
{} doesn't support createSnapshot
Error message
{} doesn't support createSnapshot What it means
FileSystem.createSnapshot(Path, String) is optional; the base class throws UnsupportedOperationException with getClass().getSimpleName() + " doesn't support createSnapshot". Snapshots are an HDFS NameNode feature: only DistributedFileSystem (and pass-through wrappers: ViewFileSystem, ChRootedFileSystem, FilterFileSystem when the inner FS supports it) plus WebHdfsFileSystem override it. Local and object-store filesystems throw.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java:3103
* @return the snapshot path.
* @throws IOException IO failure
* @throws UnsupportedOperationException if the operation is unsupported
*/
public final Path createSnapshot(Path path) throws IOException {
return createSnapshot(path, null);
}
/**
* Create a snapshot.
* @param path The directory where snapshots will be taken.
* @param snapshotName The name of the snapshot
* @return the snapshot path.
* @throws IOException IO failure
* @throws UnsupportedOperationException if the operation is unsupported
*/
public Path createSnapshot(Path path, String snapshotName)
throws IOException {
throw new UnsupportedOperationException(getClass().getSimpleName()
+ " doesn't support createSnapshot");
}
/**
* Rename a snapshot.
* @param path The directory path where the snapshot was taken
* @param snapshotOldName Old name of the snapshot
* @param snapshotNewName New name of the snapshot
* @throws IOException IO failure
* @throws UnsupportedOperationException if the operation is unsupported
* (default outcome).
*/
public void renameSnapshot(Path path, String snapshotOldName,
String snapshotNewName) throws IOException {
throw new UnsupportedOperationException(getClass().getSimpleName()
+ " doesn't support renameSnapshot");
}
View on GitHub (pinned to 2add963021)
Solutions
- Probe capability first: fs.hasPathCapability(dir, CommonPathCapabilities.FS_SNAPSHOTS) or fs instanceof DistributedFileSystem
- On HDFS, also allow snapshots on the directory first (hdfs dfsadmin -allowSnapshot <dir>) — a disabled snapshot dir yields a different, server-side error
- Catch UnsupportedOperationException and fall back to a copy-based backup (distcp) for stores without snapshots
- On object stores, use store-native versioning/bucket snapshots instead of the FileSystem API
Example fix
// before
Path snap = fs.createSnapshot(backupDir, "nightly-1");
// UnsupportedOperationException: LocalFileSystem doesn't support createSnapshot
// after
if (fs.hasPathCapability(backupDir, CommonPathCapabilities.FS_SNAPSHOTS)) {
Path snap = fs.createSnapshot(backupDir, "nightly-1");
} else {
LOG.warn("Snapshots unsupported on {}, falling back to distcp", fs.getUri());
copyBackup(backupDir);
} Defensive patterns
Strategy: try-catch
Validate before calling
import org.apache.hadoop.fs.CommonPathCapabilities;
if (fs.hasPathCapability(backupDir, CommonPathCapabilities.FS_SNAPSHOTS)) {
Path snap = fs.createSnapshot(backupDir, "nightly-1");
} Type guard
static boolean supportsSnapshots(FileSystem fs) {
return fs instanceof DistributedFileSystem;
} Try / catch
try {
fs.createSnapshot(dir, name);
} catch (UnsupportedOperationException e) {
// class named in e.getMessage() has no snapshot support: fall back to copy-based backup
} Prevention
- Gate snapshot code on FS_SNAPSHOTS capability or instanceof DistributedFileSystem
- Use fully-qualified hdfs:// paths in backup scripts to avoid fs.defaultFS drift
- On HDFS, remember allowSnapshot must be enabled per directory (a different, server-side error)
When it happens
Trigger: Calling fs.createSnapshot(dir, name) on LocalFileSystem (file://), S3A, ABFS, GCS, or HarFileSystem; snapshot/backup tooling invoked with the wrong fs.defaultFS; ViewFileSystem mounts whose target is not HDFS.
Common situations: Backup or rollback tooling written for HDFS and run in local unit tests; ops scripts pointed at the wrong cluster/scheme after config drift; distcp/Hive pipelines that snapshot before bulk changes.
Related errors
- {} doesn't support renameSnapshot
- {} doesn't support deleteSnapshot
- {} doesn't support satisfyStoragePolicy
- {} doesn't support setStoragePolicy
- {} doesn't support unsetStoragePolicy
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/85aeafe9ad949ae2.
Report an issue: GitHub.