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

  1. Verify no leftover temp files remain and delete them manually if needed
  2. Check the attached stack trace for the failing cleanup step
  3. Ignore if it occurs only at shutdown and no files remain
  4. 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

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/6dc715d56ba2f7bb. Report an issue: GitHub.