{"record":{"id":"85aeafe9ad949ae2","repo":"apache/hadoop","slug":"doesn-t-support-createsnapshot-85aeaf","errorCode":null,"errorMessage":"{} doesn't support createSnapshot","messagePattern":"(.+?) doesn't support createSnapshot","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java","lineNumber":3103,"sourceCode":"   * @return the snapshot path.\n   * @throws IOException IO failure\n   * @throws UnsupportedOperationException if the operation is unsupported\n   */\n  public final Path createSnapshot(Path path) throws IOException {\n    return createSnapshot(path, null);\n  }\n\n  /**\n   * Create a snapshot.\n   * @param path The directory where snapshots will be taken.\n   * @param snapshotName The name of the snapshot\n   * @return the snapshot path.\n   * @throws IOException IO failure\n   * @throws UnsupportedOperationException if the operation is unsupported\n   */\n  public Path createSnapshot(Path path, String snapshotName)\n      throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support createSnapshot\");\n  }\n\n  /**\n   * Rename a snapshot.\n   * @param path The directory path where the snapshot was taken\n   * @param snapshotOldName Old name of the snapshot\n   * @param snapshotNewName New name of the snapshot\n   * @throws IOException IO failure\n   * @throws UnsupportedOperationException if the operation is unsupported\n   *         (default outcome).\n   */\n  public void renameSnapshot(Path path, String snapshotOldName,\n      String snapshotNewName) throws IOException {\n    throw new UnsupportedOperationException(getClass().getSimpleName()\n        + \" doesn't support renameSnapshot\");\n  }\n","sourceCodeStart":3085,"sourceCodeEnd":3121,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L3085-L3121","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nPath snap = fs.createSnapshot(backupDir, \"nightly-1\");\n// UnsupportedOperationException: LocalFileSystem doesn't support createSnapshot\n\n// after\nif (fs.hasPathCapability(backupDir, CommonPathCapabilities.FS_SNAPSHOTS)) {\n  Path snap = fs.createSnapshot(backupDir, \"nightly-1\");\n} else {\n  LOG.warn(\"Snapshots unsupported on {}, falling back to distcp\", fs.getUri());\n  copyBackup(backupDir);\n}","handlingStrategy":"try-catch","validationCode":"import org.apache.hadoop.fs.CommonPathCapabilities;\n\nif (fs.hasPathCapability(backupDir, CommonPathCapabilities.FS_SNAPSHOTS)) {\n  Path snap = fs.createSnapshot(backupDir, \"nightly-1\");\n}","typeGuard":"static boolean supportsSnapshots(FileSystem fs) {\n  return fs instanceof DistributedFileSystem;\n}","tryCatchPattern":"try {\n  fs.createSnapshot(dir, name);\n} catch (UnsupportedOperationException e) {\n  // class named in e.getMessage() has no snapshot support: fall back to copy-based backup\n}","preventionTips":["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)"],"tags":["hadoop","filesystem","hdfs","snapshot","unsupportedoperationexception","backup"],"backgroundTag":"filesystem-snapshot-unsupported","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}