apache/cassandra · warning

Failed closing stream

Error message

Failed closing stream {}

What it means

FileUtils.close(Iterable) closes a list of streams, collecting the first exception and adding the rest as suppressed. When any individual close fails it logs 'Failed closing stream', then possibly rethrows the first failure as IOException via maybeFail.

Solutions

  1. Read the first exception (and suppressed ones) in the log for the root cause
  2. Free disk space / fix I/O errors if close failures are caused by flush on close
  3. Retry the operation (compaction, repair) after resolving the underlying issue
  4. Ensure callers handle the propagated IOException from FileUtils.close

Example fix

null
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

try {
    FileUtils.close(streams);
} catch (IOException e) {
    // first close failure is e; check e.getSuppressed() for the rest
    for (Throwable s : e.getSuppressed()) log.warn("additional close failure", s);
}

Prevention

When it happens

Trigger: Closing multiple AutoCloseables (e.g. sstable components, transaction logs) where one or more close() calls throw IOException or another Throwable.

Common situations: Compaction or streaming failure paths where several writers are closed together; disk errors while flushing final data on close.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/io/util/FileUtils.java:289

    {
        close(Arrays.asList(cs));
    }

    public static void close(Iterable<? extends Closeable> cs) throws IOException
    {
        Throwable e = null;
        for (Closeable c : cs)
        {
            try
            {
                if (c != null)
                    c.close();
            }
            catch (Throwable ex)
            {
                if (e == null) e = ex;
                else e.addSuppressed(ex);
                logger.warn("Failed closing stream {}", c, ex);
            }
        }
        maybeFail(e, IOException.class);
    }

    public static void closeQuietly(Iterable<? extends AutoCloseable> cs)
    {
        for (AutoCloseable c : cs)
        {
            try
            {
                if (c != null)
                    c.close();
            }
            catch (Exception ex)
            {
                logger.warn("Failed closing {}", c, ex);
            }

View on GitHub (pinned to 88fd0f6a0e)