apache/druid · warning
Could not delete cache file at
Error message
Could not delete cache file at [%s]
What it means
CassandraDataSegmentPuller.getSegmentFiles() writes the downloaded segment to a temp file and extracts it; in the finally block it attempts tmpFile.delete() and logs this warning if deletion returns false, leaving the cached temp file on disk. The primary error (SegmentLoadingException) is unaffected — this is only a cleanup warning.
Solutions
- Locate and delete the leftover tmp file in the segment cache directory
- Check that all streams to tmpFile are closed before delete (upgrade Druid if an older version leaks the stream)
- Verify filesystem permissions for the Druid process on the cache dir
- Fix the underlying Cassandra pull error that put the code on the failure path
Defensive patterns
Strategy: try-catch
Try / catch
try {
puller.getSegmentFiles(descriptor);
} catch (SegmentLoadingException e) {
log.warn(e, "Cassandra segment pull failed; check for leftover tmp cache files");
} Prevention
- Ensure Cassandra connectivity and schema (segment table) are correct
- Grant the Druid process write+delete permissions on the cache dir
- On Windows, beware file locks preventing tmpFile.delete(); prefer Linux hosts
- Periodically sweep stale tmp files from the segment cache location
When it happens
Trigger: Any failure path through getSegmentFiles (Cassandra I/O error, corrupt segment zip) where File.delete() on the temp file fails — typically because the file is still open/locked by an unclosed stream, or permissions prevent deletion.
Common situations: Cassandra storage misconfiguration or outage triggering the failure path; OS (Windows) holding the file lock; cache directory owned by another user; disk full earlier in the flow.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- Failed to remove output directory
- Failed to remove output directory
- Asked to load path[ ], but it doesn't exist.
- Cannot delete temp file
- Could not create temporary file
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/fd42e238bb745eb4.
Report an issue: GitHub.
Appendix: source
Thrown at extensions-contrib/cassandra-storage/src/main/java/org/apache/druid/storage/cassandra/CassandraDataSegmentPuller.java:104
log.info(
"Pull of file[%s] completed in %,d millis (%s bytes)", key, System.currentTimeMillis() - startTime,
result.size()
);
return result;
}
catch (Exception e) {
try {
FileUtils.deleteDirectory(outDir);
}
catch (IOException e1) {
log.error(e1, "Error clearing segment directory [%s]", outDir.getAbsolutePath());
e.addSuppressed(e1);
}
throw new SegmentLoadingException(e, e.getMessage());
}
finally {
if (!tmpFile.delete()) {
log.warn("Could not delete cache file at [%s]", tmpFile.getAbsolutePath());
}
}
}
}
View on GitHub (pinned to 9b90983fd2)