apache/cassandra · warning
Exception thrown when cleaning up files to delete on exit, c
Error message
Exception thrown when cleaning up files to delete on exit, continuing.
What it means
At shutdown, PathUtils runs the on-exit deletion threads to remove files registered for delete-on-exit. If running those threads (or removing the shutdown hook) throws, it logs this warning and continues shutdown anyway.
Source
Thrown at src/java/org/apache/cassandra/io/util/PathUtils.java:691
private static void runOnExitThreadsAndClear()
{
List<Thread> toRun;
synchronized (onExitThreads)
{
toRun = new ArrayList<>(onExitThreads);
onExitThreads.clear();
}
Runtime runtime = Runtime.getRuntime();
toRun.forEach(onExitThread -> {
try
{
runtime.removeShutdownHook(onExitThread);
//noinspection CallToThreadRun
onExitThread.run();
}
catch (Exception ex)
{
logger.warn("Exception thrown when cleaning up files to delete on exit, continuing.", ex);
}
});
}
private static void clearOnExitThreads()
{
synchronized (onExitThreads)
{
Runtime runtime = Runtime.getRuntime();
onExitThreads.forEach(runtime::removeShutdownHook);
onExitThreads.clear();
}
}
DeleteOnExit()
{
final Thread onExitThread = new Thread(this); // checkstyle: permit this instantiation
synchronized (onExitThreads)View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Verify no leftover temp files remain and delete them manually if needed
- Check the attached stack trace for the failing cleanup step
- Ignore if it occurs only at shutdown and no files remain
- Investigate what deleted the files before the hook ran if it recurs
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
PathUtils.deleteOnExitIfEmpty(dir); // or equivalent registration
} catch (Exception e) {
log.warn("could not register delete-on-exit; schedule manual cleanup", e);
} Prevention
- Do not rely on delete-on-exit for critical cleanup; clean up explicitly
- Check for leftover temp files after unclean shutdowns
- Investigate what removes registered files before the shutdown hook runs
- Treat shutdown-time cleanup failures as best-effort and verify state at startup
When it happens
Trigger: JVM shutdown with files registered via File.deleteOnExit-style tracking, where the cleanup thread's run() throws (e.g. files already deleted, filesystem unavailable, hook issues).
Common situations: Node shutdown after a crash or forceful kill leaving stale registrations; temp/sandbox files already removed before exit; unclean filesystem state at shutdown.
Related errors
- Failed to remove hard link files
- Unable to delete storage-attached index component file {} du
- Failed to delete {} on exit
- Failed importing SSTables
- Unable to resolve canonical path for
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/6dc715d56ba2f7bb.
Report an issue: GitHub.