{"record":{"id":"773bb7cf7f55db83","repo":"apache/hadoop","slug":"src-shouldn-t-enable-snapshot","errorCode":null,"errorMessage":"{src} shouldn't enable snapshot.","messagePattern":"(.+?) shouldn't enable snapshot\\.","errorType":"validation","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-federation-balance/src/main/java/org/apache/hadoop/tools/fedbalance/DistCpProcedure.java","lineNumber":191,"sourceCode":"      return true;\n    default:\n      throw new IOException(\"Unexpected stage=\" + stage);\n    }\n  }\n\n  /**\n   * Pre check of src and dst.\n   */\n  void preCheck() throws IOException {\n    FileStatus status = srcFs.getFileStatus(src);\n    if (!status.isDirectory()) {\n      throw new IOException(src + \" should be a directory.\");\n    }\n    if (dstFs.exists(dst)) {\n      throw new IOException(dst + \" already exists.\");\n    }\n    if (srcFs.exists(new Path(src, HdfsConstants.DOT_SNAPSHOT_DIR))) {\n      throw new IOException(src + \" shouldn't enable snapshot.\");\n    }\n    updateStage(Stage.INIT_DISTCP);\n  }\n\n  /**\n   * The initial distcp. Copying src to dst.\n   */\n  void initDistCp() throws IOException, RetryException {\n    RunningJobStatus job = getCurrentJob();\n    if (job != null) {\n      // the distcp has been submitted.\n      if (job.isComplete()) {\n        jobId = null; // unset jobId because the job is done.\n        if (job.isSuccessful()) {\n          updateStage(Stage.DIFF_DISTCP);\n          return;\n        } else {\n          LOG.warn(\"DistCp failed. Failure={}\", job.getFailureInfo());","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-federation-balance/src/main/java/org/apache/hadoop/tools/fedbalance/DistCpProcedure.java#L173-L209","documentation":"The third clause of DistCpProcedure.preCheck(): fedbalance rejects a source that already has snapshots enabled, detected via existence of src/.snapshot (HdfsConstants.DOT_SNAPSHOT_DIR). The procedure needs full control of snapshots on src (pathCheckBeforeInitDistcp calls allowSnapshot(src) and later creates its own CURRENT/LAST snapshots for diff distcp), so pre-existing snapshot state is refused up front.","triggerScenarios":"Submitting a fedbalance job where src is a snapshottable directory or has any snapshot: srcFs.exists(new Path(src, '.snapshot')) returns true in preCheck().","commonSituations":"Balancing directories already covered by snapshot-based backup jobs; leftover fedbalance snapshots from an aborted earlier run; dirs made snapshottable by admin tooling for DR purposes.","solutions":["Delete all snapshots on src ('hdfs dfsadmin -deleteSnapshot <src> <name>' for each) and then 'hdfs dfsadmin -disallowSnapshot <src>'.","Resubmit the fedbalance job once 'hdfs dfs -ls <src>/.snapshot' fails (snapshot state fully removed).","If snapshots must stay enabled for backups, balance a different tree or restructure so the balanced subtree is not snapshottable."],"exampleFix":"# before\nhdfs fedbalance -src hdfs://ns1/data -dst hdfs://ns2/data   # /data is snapshottable\n\n# after\nhdfs dfs -ls hdfs://ns1/data/.snapshot          # list existing snapshots\nhdfs dfsadmin -deleteSnapshot hdfs://ns1/data snap1\nhdfs dfsadmin -disallowSnapshot hdfs://ns1/data\nhdfs fedbalance -src hdfs://ns1/data -dst hdfs://ns2/data","handlingStrategy":"validation","validationCode":"Path src = new Path(\"hdfs://ns1/data\");\nFileSystem srcFs = src.getFileSystem(conf);\nif (srcFs.exists(new Path(src, \".snapshot\"))) {\n  throw new IllegalStateException(\"src is snapshottable/has snapshots; delete snapshots and disallowSnapshot before fedbalance\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check 'hdfs dfs -ls <src>/.snapshot' fails before submitting fedbalance.","Keep fedbalance-managed trees separate from snapshot-backed backup trees."],"tags":["fedbalance","federation-balance","hdfs-snapshot","precheck","distcp"],"backgroundTag":"hdfs-snapshot-conflict","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}