{"record":{"id":"33e5c94ebbcf4e7a","repo":"apache/hadoop","slug":"the-directory-cannot-be-deleted-since-is-sna","errorCode":null,"errorMessage":"The directory {} cannot be deleted since {} is snapshottable and already has snapshots","messagePattern":"The directory (.+?) cannot be deleted since (.+?) is snapshottable and already has snapshots","errorType":"exception","errorClass":"SnapshotException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirSnapshotOp.java","lineNumber":339,"sourceCode":"  /**\n   * Check if the given INode (or one of its descendants) is snapshottable and\n   * already has snapshots.\n   *\n   * @param target The given INode\n   * @param snapshottableDirs The list of directories that are snapshottable\n   *                          but do not have snapshots yet\n   */\n  private static void checkSnapshot(\n      INode target, List<INodeDirectory> snapshottableDirs)\n      throws SnapshotException {\n    if (target.isDirectory()) {\n      INodeDirectory targetDir = target.asDirectory();\n      DirectorySnapshottableFeature sf = targetDir\n          .getDirectorySnapshottableFeature();\n      if (sf != null) {\n        if (sf.getNumSnapshots() > 0) {\n          String fullPath = targetDir.getFullPathName();\n          throw new SnapshotException(\"The directory \" + fullPath\n              + \" cannot be deleted since \" + fullPath\n              + \" is snapshottable and already has snapshots\");\n        } else {\n          if (snapshottableDirs != null) {\n            snapshottableDirs.add(targetDir);\n          }\n        }\n      }\n      for (INode child : targetDir.getChildrenList(Snapshot.CURRENT_STATE_ID)) {\n        checkSnapshot(child, snapshottableDirs);\n      }\n    }\n  }\n\n  /**\n   * Check if the given path (or one of its descendants) is snapshottable and\n   * already has snapshots.\n   *","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirSnapshotOp.java#L321-L357","documentation":"Error \"The directory {} cannot be deleted since {} is snapshottable and already has snapshots\" thrown in apache/hadoop.","triggerScenarios":"Deleting a snapshottable directory that already has snapshots; the snapshots must be deleted first.","commonSituations":"See trigger scenarios.","solutions":["Delete all snapshots of the directory first (hdfs dfs -deleteSnapshot) then disallow snapshots and delete it."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}