{"record":{"id":"14217fa66a3eb6f9","repo":"apache/druid","slug":"unable-to-close-channel-for-name","errorCode":null,"errorMessage":"Unable to close channel for name : ","messagePattern":"Unable to close channel for name : ","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/frame/processor/SuperSorter.java","lineNumber":1006,"sourceCode":"  {\n    if (!isAllDone() || activeProcessors != 0) {\n      // This condition indicates a logic bug.\n      throw new ISE(\"Improper cleanup\");\n    }\n\n    if (log.isDebugEnabled()) {\n      log.debug(stateString());\n    }\n\n    outputsReadyByLevel.clear();\n    inputBuffer.clear();\n    for (Map.Entry<String, PartitionedOutputChannel> cleanupEntry :\n        levelAndRankToReadableChannelMap.entrySet()) {\n      try {\n        cleanupEntry.getValue().getReadableChannelSupplier().get().close();\n      }\n      catch (IOException e) {\n        throw new UncheckedIOException(\"Unable to close channel for name : \" + cleanupEntry.getKey(), e);\n      }\n    }\n    levelAndRankToReadableChannelMap.clear();\n\n    if (!inputChannelsToRead.isEmpty()) {\n      for (final ReadableFrameChannel inputChannel : inputChannels) {\n        CloseableUtils.closeAndSuppressExceptions(\n            inputChannel::close,\n            e -> log.warn(e, \"Could not close input channel\")\n        );\n      }\n\n      inputChannels.forEach(ReadableFrameChannel::close);\n    }\n\n    inputChannelsToRead.clear();\n  }\n","sourceCodeStart":988,"sourceCodeEnd":1024,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/frame/processor/SuperSorter.java#L988-L1024","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the druid interim/temp storage directory for free space, permissions, and that the backing file still exists.","Look for external cleanup jobs (tmpwatch, k8s emptyDir eviction) that might delete spill files mid-query and exclude that directory.","Inspect the underlying IOException cause in the stack trace — 'No such file' vs 'No space left' lead to different fixes.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify interim storage is writable and has space before query execution\nFiles.isDirectory(interimPath) && Files.isWritable(interimPath)","typeGuard":null,"tryCatchPattern":"try {\n  sorter.cleanUp();\n} catch (UncheckedIOException e) {\n  log.warn(e, \"Failed to close sorter channel: %s\", e.getMessage());\n  // query output may still be valid; surface as resource-leak warning\n}","preventionTips":["Monitor disk space and mount state of the interim spill directory.","Exclude druid interim paths from external tmp-cleaning jobs.","Keep consistent permissions on the frame-file directory across worker restarts."],"tags":["io","file-close","filesystem"],"backgroundTag":"file-close-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}