{"record":{"id":"b0d68bae29a7888c","repo":"apache/hadoop","slug":"failed-to-removesnapshot-from-unexpected-pr","errorCode":null,"errorMessage":"Failed to removeSnapshot {} from {}: Unexpected prior (={}) when dfs.namenode.snapshot.deletion.ordered is {}","messagePattern":"Failed to removeSnapshot (.+?) from (.+?): Unexpected prior \\(=(.+?)\\) when dfs\\.namenode\\.snapshot\\.deletion\\.ordered is (.+?)","errorType":"exception","errorClass":"SnapshotException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java","lineNumber":350,"sourceCode":"    final Snapshot.Root snapshotRoot = dir.getDirectorySnapshottableFeature()\n        .getSnapshotByName(dir, snapshotName)\n        .getRoot();\n\n    if (!snapshotRoot.isMarkedAsDeleted()) {\n      throw new SnapshotException(\"Failed to gcDeletedSnapshot \"\n          + snapshotName + \" from \" + dir.getFullPathName()\n          + \": snapshot is not marked as deleted\");\n    }\n  }\n\n  void assertPrior(INodeDirectory dir, String snapshotName, int prior)\n      throws SnapshotException {\n    if (!isSnapshotDeletionOrdered()) {\n      return;\n    }\n    // prior must not exist\n    if (prior != Snapshot.NO_SNAPSHOT_ID) {\n      throw new SnapshotException(\"Failed to removeSnapshot \"\n          + snapshotName + \" from \" + dir.getFullPathName()\n          + \": Unexpected prior (=\" + prior + \") when \"\n          + DFS_NAMENODE_SNAPSHOT_DELETION_ORDERED\n          + \" is \" + isSnapshotDeletionOrdered());\n    }\n  }\n\n  void assertFirstSnapshot(INodeDirectory dir,\n      DirectorySnapshottableFeature snapshottable, Snapshot snapshot)\n      throws SnapshotException {\n    final INodeDirectoryAttributes first\n        = snapshottable.getDiffs().getFirstSnapshotINode();\n    if (snapshot.getRoot() != first) {\n      throw new SnapshotException(\"Failed to delete snapshot \" + snapshot\n          + \" from \" + dir.getFullPathName() + \" since \" + snapshot\n          + \" is not the first snapshot (=\" + first + \") and \"\n          + DFS_NAMENODE_SNAPSHOT_DELETION_ORDERED\n          + \" is \" + isSnapshotDeletionOrdered());","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/snapshot/SnapshotManager.java#L332-L368","documentation":"Error \"Failed to removeSnapshot {} from {}: Unexpected prior (={}) when dfs.namenode.snapshot.deletion.ordered is {}\" thrown in apache/hadoop.","triggerScenarios":"Snapshot removal encounters an unexpected prior snapshot while ordered deletion is enforced.","commonSituations":"Deleting snapshots out of order with dfs.namenode.snapshot.deletion.ordered=true.","solutions":["Check the value of dfs.namenode.snapshot.deletion.ordered and delete snapshots in order, or set it to false for out-of-order deletion."],"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"}