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
- 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
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
- Poll status until SUCCESS before requesting results
- Inspect server logs for the wrapped cause
- Handle MSQ task failure/cancellation upstream
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
- Expected a single column but got
- Expected a single row but got
- Failed to handle query
- Query [ ] was not found. The query details are no longer…
- The current user[ ] cannot view query id[ ] since the query…
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)