apache/druid · error · ISE

Unable to stream results back for query

Error message

Unable to stream results back for query[%s]

What it means

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.

Solutions

  1. Inspect the server log for the wrapped cause under 'Unable to stream results back for query[%s]'
  2. Re-run the query and check the statement's status endpoint for the underlying MSQ failure before fetching results
  3. Ensure the query completes successfully (status SUCCESS) before consuming the results stream
  4. If caused by serialization, check row types match the declared signature
Defensive patterns

Strategy: try-catch

Validate before calling

// check query state before streaming results
if (statement.getState() != SqlStatementState.SUCCESS) {
  throw new IllegalStateException("Query not complete: " + statement.getState());
}

Try / catch

try {
  // consume results stream
} catch (IllegalStateException e) {
  Throwable root = e.getCause();
  log.error("Result stream failed for query", root);
  // inspect statement status for the real MSQ failure
}

Prevention

When it happens

Trigger: 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.

Common situations: MSQ task failed while the client was awaiting results; controller task disappeared; serialization failure of the first rows; interrupted request.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java:898

  private void resultPusher(
      String queryId,
      Optional<List<ColumnNameAndTypes>> signature,
      Closer closer,
      Optional<Yielder<Object[]>> results,
      CountingOutputStream os,
      ResultFormat resultFormat
  ) throws IOException
  {
    try {
      try (final ResultFormat.Writer writer = resultFormat.createFormatter(os, jsonMapper)) {
        Yielder<Object[]> yielder = results.get();
        List<ColumnNameAndTypes> rowSignature = signature.get();
        resultPusherInternal(writer, yielder, rowSignature);
      }
      catch (Exception e) {
        log.error(e, "Unable to stream results back for query[%s]", queryId);
        throw new ISE(e, "Unable to stream results back for query[%s]", queryId);
      }
    }
    catch (Exception e) {
      log.error(e, "Unable to stream results back for query[%s]", queryId);
      throw new ISE(e, "Unable to stream results back for query[%s]", queryId);
    }
    finally {
      closer.close();
    }
  }

  @VisibleForTesting
  static void resultPusherInternal(
      ResultFormat.Writer writer,
      Yielder<Object[]> yielder,
      List<ColumnNameAndTypes> rowSignature
  ) throws IOException
  {

View on GitHub (pinned to 9b90983fd2)