{"record":{"id":"bb1f98b60e772f8d","repo":"apache/hadoop","slug":"failed-to-move-block-file-for-this-from-srcfi","errorCode":null,"errorMessage":"Failed to move block file for ${this} from ${srcfile} to ${destfile.getAbsolutePath()}","messagePattern":"Failed to move block file for (.+?) from (.+?) to (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/LocalReplica.java","lineNumber":341,"sourceCode":"    return getMetaFile().length();\n  }\n\n  @Override\n  public boolean renameMeta(URI destURI) throws IOException {\n    return renameFile(getMetaFile(), new File(destURI));\n  }\n\n  @Override\n  public boolean renameData(URI destURI) throws IOException {\n    return renameFile(getBlockFile(), new File(destURI));\n  }\n\n  private boolean renameFile(File srcfile, File destfile) throws IOException {\n    try {\n      getFileIoProvider().rename(getVolume(), srcfile, destfile);\n      return true;\n    } catch (IOException e) {\n      throw new IOException(\"Failed to move block file for \" + this\n          + \" from \" + srcfile + \" to \" + destfile.getAbsolutePath(), e);\n    }\n  }\n\n  @Override\n  public void updateWithReplica(StorageLocation replicaLocation) {\n    // for local replicas, the replica location is assumed to be a file.\n    File diskFile = null;\n    try {\n      diskFile = new File(replicaLocation.getUri());\n    } catch (IllegalArgumentException e) {\n      diskFile = null;\n    }\n\n    if (null == diskFile) {\n      setDirInternal(null);\n    } else {\n      setDirInternal(diskFile.getParentFile());","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/LocalReplica.java#L323-L359","documentation":"renameFile() wraps failures of FileIoProvider.rename while moving a block file — e.g., renameData(destURI) relocating a block during lazy-persist spill from RAM_DISK to disk or other finalized moves. The original IOException from the rename (destination missing, permission denied, ENOSPC, read-only or cross-device semantics) is chained as the cause of the new IOException naming src and dest.","triggerScenarios":"renameData()/renameFile where the destination directory does not exist, the destination volume is read-only or full, permissions changed under the DataNode, or the volume was unmounted mid-operation.","commonSituations":"Lazy-persist writes spilling from RAM_DISK to a full or read-only disk; destination finalized subdir missing after partial volume cleanup; permission drift on data dirs; volume unmounted between check and rename.","solutions":["Check the destination volume for space (`df -h`) and read-only mounts; free space or remount read-write and retry.","Verify ownership/permissions on the destination directory tree and fix with chown/chmod for the DataNode user.","Confirm the destination directory exists and the volume is still mounted (`mount`, ls of the volume root) before retrying.","For lazy-persist spills, ensure the fallback disk volume has capacity and is writable (dfs.datanode.data.dir on disk, not only ram_disk)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"File dest = new File(destURI);\nif (!dest.getParentFile().isDirectory() || !dest.getParentFile().canWrite()) {\n  // destination dir missing or not writable: fix before renameData\n}","typeGuard":null,"tryCatchPattern":"try {\n  replica.renameData(destURI);\n} catch (IOException e) {\n  // e.getCause() holds the real rename failure: check dest dir, perms, df -h, mount state;\n  // fix and retry once; do not lose the block — keep the source until rename succeeds\n}","preventionTips":["Ensure destination volumes have free space and write permissions before lazy-persist spill or block moves","Mount data volumes read-write and verify they stay mounted during long-running operations","Monitor disk-full conditions on all volumes that receive renamed block files"],"tags":["filesystem","rename","block","disk-full","hdfs","datanode"],"backgroundTag":"file-rename-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}