apache/hadoop · warning · IOException

Failed to delete the mapped file: {filePath}

Error message

Failed to delete the mapped file: {filePath}

What it means

deleteMappedFile calls Files.deleteIfExists and throws when it returns false - the mapped file was already gone (another cleanup won the race or the temp dir was purged) or cannot be unlinked (still mapped/open on some platforms, permissions). Only intermediate checksum temp data is affected, never block data.

Source

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

      }

      @Override
      public InputStream getDataInputStream(long seekOffset)
          throws IOException {
        return Files.newInputStream(blockFile.toPath());
      }
    };

    FsDatasetImpl.computeChecksum(wrapper, dstMeta, smallBufferSize, conf);
  }

  public static void deleteMappedFile(String filePath) throws IOException {
    if (filePath == null) {
      throw new IOException("The filePath should not be null!");
    }
    boolean result = Files.deleteIfExists(Paths.get(filePath));
    if (!result) {
      throw new IOException(
          "Failed to delete the mapped file: " + filePath);
    }
  }
}

View on GitHub (pinned to 2add963021)

Solutions

  1. If occasional during shutdown, treat as noise - the desired end state (file absent) already holds.
  2. Check the stack for duplicate cleanup calls (two finally blocks deleting the same path) and remove the double delete.
  3. Where unlink-while-mapped semantics apply, close/unmap the buffer before deleting.
  4. Verify the temp location under dfs.datanode.data.dir is not swept by external tooling mid-run.
Defensive patterns

Strategy: try-catch

Validate before calling

if (filePath != null && Files.exists(Paths.get(filePath))) {
  FsDatasetUtil.deleteMappedFile(filePath);
}

Try / catch

try {
  FsDatasetUtil.deleteMappedFile(path);
} catch (IOException e) {
  if (Files.notExists(Paths.get(path))) {
    // already gone: goal state reached, ignore
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Concurrent cleanup racing (double invocation of the cleanup path); file already removed by temp-dir eviction; the mapped file still open where unlink requires closure; missing parent directory.

Common situations: Mostly benign, appearing when two shutdown paths clean the same mapped file; recurring hits suggest double-cleanup bugs in a patched build.

Related errors


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