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
- If occasional during shutdown, treat as noise - the desired end state (file absent) already holds.
- Check the stack for duplicate cleanup calls (two finally blocks deleting the same path) and remove the double delete.
- Where unlink-while-mapped semantics apply, close/unmap the buffer before deleting.
- 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
- Use a single cleanup path per mapped file; avoid double finally deletes.
- Unmap/close the buffer before deleting on platforms that forbid unlink-while-open.
- Keep external temp-dir sweepers away from DN storage directories.
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
- Meta-data not found for {block}
- Checksum failed at {failedPos} for replica: {replica}
- FsDatasetSpi has not been initialized
- Failed to create temporary file for {}. File {} should be c
- Meta file for {} not found.
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/eb897bb62e05fe11.
Report an issue: GitHub.