{"record":{"id":"37568e24e06bb03e","repo":"apache/druid","slug":"problem-closing-resources-for-segment-s","errorCode":null,"errorMessage":"Problem closing resources for segment[%s]","messagePattern":"Problem closing resources for segment\\[(.+?)\\]","errorType":"exception","errorClass":"RE","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/query/operator/SegmentToRowsAndColumnsOperator.java","lineNumber":66,"sourceCode":"        throw DruidException.defensive(\"Segment [%s] cannot shapeshift\", segment.getDebugString());\n      }\n      RowsAndColumns rac;\n      if (shifty instanceof RowsAndColumns) {\n        rac = (RowsAndColumns) shifty;\n      } else {\n        rac = shifty.as(RowsAndColumns.class);\n      }\n\n      if (rac == null) {\n        throw new ISE(\"Cannot work with segment of type[%s]\", segment.getClass());\n      }\n\n      // After pushing in a single object, we are done, so ignore the signal and call completed()\n      receiver.push(rac);\n      receiver.completed();\n    }\n    catch (IOException e) {\n      throw new RE(e, \"Problem closing resources for segment[%s]\", segment.getId());\n    }\n    return null;\n  }\n}\n","sourceCodeStart":48,"sourceCodeEnd":71,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/query/operator/SegmentToRowsAndColumnsOperator.java#L48-L71","documentation":"SegmentToRowsAndColumnsOperator wraps its segment conversion in try/catch to release segment resources on failure (close() may throw IOException). When closing the segment's resources fails, the original error path surfaces as this RE naming the segment id.","triggerScenarios":"An IOException (or error during close in the finally path) while releasing the segment after pushing rows — typically a failure closing underlying storage used by the segment.","commonSituations":"Disk I/O errors or exhausted file descriptors when reading from memory-mapped/disk-backed segments, cancelled queries racing with segment cleanup, or storage device problems on historical nodes.","solutions":["Check the wrapped cause for the root I/O problem (disk errors, fd limits) and fix the underlying storage issue","Increase file descriptor limits (ulimit) if handles are exhausted on busy historicals","Retry the query; if reproducible, inspect the specific segment's backing files for corruption"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  operator.go(receiver, cont);\n} catch (RE e) {\n  if (e.getMessage() != null && e.getMessage().startsWith(\"Problem closing resources for segment\")) {\n    logger.warn(e.getCause(), \"Segment cleanup failed for %s\", e.getCause());\n  } else throw e;\n}","preventionTips":["Raise file descriptor limits on historical nodes running operator queries","Monitor disk I/O health; close failures usually mirror read failures","Ensure queries are cancelled through the normal path so segments close once, not concurrently"],"tags":["io","segment","resource-cleanup","operator"],"backgroundTag":"broken-pipe","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}