apache/hadoop · error · IOException

Unable to cleanup unlinked tmp file {}

Error message

Unable to cleanup unlinked tmp file {}

What it means

Error "Unable to cleanup unlinked tmp file {}" thrown in apache/hadoop.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/BlockPoolSlice.java:570

      }
    }
    if (!exceptions.isEmpty()) {
      throw MultipleIOException.createIOException(exceptions);
    }
  }

  /**
   * Recover an unlinked tmp file on datanode restart. If the original block
   * does not exist, then the tmp file is renamed to be the
   * original file name and the original name is returned; otherwise the tmp
   * file is deleted and null is returned.
   */
  File recoverTempUnlinkedBlock(File unlinkedTmp) throws IOException {
    File blockFile = FsDatasetUtil.getOrigFile(unlinkedTmp);
    if (blockFile.exists()) {
      // If the original block file still exists, then no recovery is needed.
      if (!fileIoProvider.delete(volume, unlinkedTmp)) {
        throw new IOException("Unable to cleanup unlinked tmp file " +
            unlinkedTmp);
      }
      return null;
    } else {
      fileIoProvider.rename(volume, unlinkedTmp, blockFile);
      return blockFile;
    }
  }


  /**
   * Move replicas in the lazy persist directory to their corresponding locations
   * in the finalized directory.
   * @return number of replicas recovered.
   */
  private int moveLazyPersistReplicasToFinalized(File source)
      throws IOException {
    File[] files = fileIoProvider.listFiles(volume, source);

View on GitHub (pinned to 2add963021)

Solutions

  1. Check the DataNode log for the underlying IOException cause (permissions, busy file, failed disk).
  2. Verify the volume filesystem is healthy; run fsck if needed and restart the DataNode so cleanup is retried.
  3. Manually remove the stale .unlinked tmp file if the filesystem is healthy but the file was left behind.

When it happens

Trigger: Volume scanning/cleanup when an unlinked tmp block file cannot be deleted, typically a permissions or filesystem error.

Common situations: See trigger scenarios.


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