{"record":{"id":"cc064794afcc39fb","repo":"apache/druid","slug":"unable-to-stream-results-back-for-query-s","errorCode":null,"errorMessage":"Unable to stream results back for query[%s]","messagePattern":"Unable to stream results back for query\\[(.+?)\\]","errorType":"http","errorClass":"ISE","httpStatus":500,"severity":"error","filePath":"multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java","lineNumber":898,"sourceCode":"\n  private void resultPusher(\n      String queryId,\n      Optional<List<ColumnNameAndTypes>> signature,\n      Closer closer,\n      Optional<Yielder<Object[]>> results,\n      CountingOutputStream os,\n      ResultFormat resultFormat\n  ) throws IOException\n  {\n    try {\n      try (final ResultFormat.Writer writer = resultFormat.createFormatter(os, jsonMapper)) {\n        Yielder<Object[]> yielder = results.get();\n        List<ColumnNameAndTypes> rowSignature = signature.get();\n        resultPusherInternal(writer, yielder, rowSignature);\n      }\n      catch (Exception e) {\n        log.error(e, \"Unable to stream results back for query[%s]\", queryId);\n        throw new ISE(e, \"Unable to stream results back for query[%s]\", queryId);\n      }\n    }\n    catch (Exception e) {\n      log.error(e, \"Unable to stream results back for query[%s]\", queryId);\n      throw new ISE(e, \"Unable to stream results back for query[%s]\", queryId);\n    }\n    finally {\n      closer.close();\n    }\n  }\n\n  @VisibleForTesting\n  static void resultPusherInternal(\n      ResultFormat.Writer writer,\n      Yielder<Object[]> yielder,\n      List<ColumnNameAndTypes> rowSignature\n  ) throws IOException\n  {","sourceCodeStart":880,"sourceCodeEnd":916,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java#L880-L916","documentation":"Internal error raised by the results-pushing lambda of the SQL statements endpoint when an exception occurs while obtaining the yielder, row signature, or writing the first batch of rows to the HTTP response. It wraps the underlying exception and surfaces as a 500 to the client.","triggerScenarios":"resultPusher throws while calling results.get() (query failed/canceled mid-stream), signature.get() throws, or resultPusherInternal throws on its first rows before the outer catch block takes over.","commonSituations":"MSQ task failed while the client was awaiting results; controller task disappeared; serialization failure of the first rows; interrupted request.","solutions":["Inspect the server log for the wrapped cause under 'Unable to stream results back for query[%s]'","Re-run the query and check the statement's status endpoint for the underlying MSQ failure before fetching results","Ensure the query completes successfully (status SUCCESS) before consuming the results stream","If caused by serialization, check row types match the declared signature"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check query state before streaming results\nif (statement.getState() != SqlStatementState.SUCCESS) {\n  throw new IllegalStateException(\"Query not complete: \" + statement.getState());\n}","typeGuard":null,"tryCatchPattern":"try {\n  // consume results stream\n} catch (IllegalStateException e) {\n  Throwable root = e.getCause();\n  log.error(\"Result stream failed for query\", root);\n  // inspect statement status for the real MSQ failure\n}","preventionTips":["Poll status until SUCCESS before requesting results","Inspect server logs for the wrapped cause","Handle MSQ task failure/cancellation upstream"],"tags":["msq","streaming","rest-api"],"backgroundTag":"internal-invariant-violation","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"}