apache/hadoop · error · SnapshotException

The directory cannot be deleted since is snapshottable and…

Error message

The directory {} cannot be deleted since {} is snapshottable and already has snapshots

What it means

Recursive guard in FSDirSnapshotOp.checkSnapshot while deleting/renaming: the target directory (or an ancestor) was made snapshottable and already contains snapshots, so deleting its state would destroy snapshot data and the operation is refused.

Solutions

  1. Delete all snapshots of the directory first (hdfs dfs -deleteSnapshot) then disallow snapshots and delete it.
Defensive patterns

Strategy: validation

When it happens

Trigger: Deleting a snapshottable directory that already has snapshots; the snapshots must be deleted first.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirSnapshotOp.java:339

  /**
   * Check if the given INode (or one of its descendants) is snapshottable and
   * already has snapshots.
   *
   * @param target The given INode
   * @param snapshottableDirs The list of directories that are snapshottable
   *                          but do not have snapshots yet
   */
  private static void checkSnapshot(
      INode target, List<INodeDirectory> snapshottableDirs)
      throws SnapshotException {
    if (target.isDirectory()) {
      INodeDirectory targetDir = target.asDirectory();
      DirectorySnapshottableFeature sf = targetDir
          .getDirectorySnapshottableFeature();
      if (sf != null) {
        if (sf.getNumSnapshots() > 0) {
          String fullPath = targetDir.getFullPathName();
          throw new SnapshotException("The directory " + fullPath
              + " cannot be deleted since " + fullPath
              + " is snapshottable and already has snapshots");
        } else {
          if (snapshottableDirs != null) {
            snapshottableDirs.add(targetDir);
          }
        }
      }
      for (INode child : targetDir.getChildrenList(Snapshot.CURRENT_STATE_ID)) {
        checkSnapshot(child, snapshottableDirs);
      }
    }
  }

  /**
   * Check if the given path (or one of its descendants) is snapshottable and
   * already has snapshots.
   *

View on GitHub (pinned to 2add963021)