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

  1. Locate and delete the leftover tmp file in the segment cache directory
  2. Check that all streams to tmpFile are closed before delete (upgrade Druid if an older version leaks the stream)
  3. Verify filesystem permissions for the Druid process on the cache dir
  4. 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

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


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)