apache/druid · error · UncheckedIOException

Unable to close channel for name :

Error message

Unable to close channel for name : 

What it means

During SuperSorter cleanup, each partitioned output channel's readable channel supplier is closed; if close() throws an IOException it is rethrown as UncheckedIOException with the channel name. This means a frame file backing one of the sorter's output channels could not be released, typically pointing at filesystem problems rather than sorter logic. Cleanup aborts with the offending channel named in the message.

Source

Thrown at processing/src/main/java/org/apache/druid/frame/processor/SuperSorter.java:1006

  {
    if (!isAllDone() || activeProcessors != 0) {
      // This condition indicates a logic bug.
      throw new ISE("Improper cleanup");
    }

    if (log.isDebugEnabled()) {
      log.debug(stateString());
    }

    outputsReadyByLevel.clear();
    inputBuffer.clear();
    for (Map.Entry<String, PartitionedOutputChannel> cleanupEntry :
        levelAndRankToReadableChannelMap.entrySet()) {
      try {
        cleanupEntry.getValue().getReadableChannelSupplier().get().close();
      }
      catch (IOException e) {
        throw new UncheckedIOException("Unable to close channel for name : " + cleanupEntry.getKey(), e);
      }
    }
    levelAndRankToReadableChannelMap.clear();

    if (!inputChannelsToRead.isEmpty()) {
      for (final ReadableFrameChannel inputChannel : inputChannels) {
        CloseableUtils.closeAndSuppressExceptions(
            inputChannel::close,
            e -> log.warn(e, "Could not close input channel")
        );
      }

      inputChannels.forEach(ReadableFrameChannel::close);
    }

    inputChannelsToRead.clear();
  }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Check the druid interim/temp storage directory for free space, permissions, and that the backing file still exists.
  2. Look for external cleanup jobs (tmpwatch, k8s emptyDir eviction) that might delete spill files mid-query and exclude that directory.
  3. Inspect the underlying IOException cause in the stack trace — 'No such file' vs 'No space left' lead to different fixes.
  4. If only cleanup fails after results were produced, treat it as a resource leak warning but investigate disk hygiene; the query output may still be valid.
Defensive patterns

Strategy: try-catch

Validate before calling

// Verify interim storage is writable and has space before query execution
Files.isDirectory(interimPath) && Files.isWritable(interimPath)

Try / catch

try {
  sorter.cleanUp();
} catch (UncheckedIOException e) {
  log.warn(e, "Failed to close sorter channel: %s", e.getMessage());
  // query output may still be valid; surface as resource-leak warning
}

Prevention

When it happens

Trigger: Closing a ReadableFrameChannel whose backing file was deleted, is on a full/unmounted filesystem, or whose file handle is in a bad state; occurs in cleanUp()'s loop over levelAndRankToReadableChannelMap when getReadableChannelSupplier().get().close() fails.

Common situations: Disks full or remounted read-only during query execution; interim files cleaned by an external process (e.g., tmp cleaner) before the sorter finished; permission changes on the druid intermediate spill directory.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/14217fa66a3eb6f9. Report an issue: GitHub.