apache/druid · error · IOException

Interrupted!

Error message

Interrupted!

What it means

AppendableByteArrayInputStream.scanThroughBytesAndDoSomething waits on a monitor for more bytes to arrive from the async HTTP response. If the waiting thread is interrupted, it restores the interrupt flag and throws IOException("Interrupted!") to abort the read. The underlying cause (e.g. connection closed or stream aborted) is also surfaced as an IOException when the producer recorded a throwable.

Solutions

  1. Treat it as cancellation: check Thread.currentThread().isInterrupted() and unwind gracefully; do not swallow the flag (the code already re-interrupts).
  2. If interruption is unexpected, find who interrupts the thread (query cancellation, timeout, shutdown hook) and fix the lifecycle.
  3. Retry the HTTP fetch if the operation is idempotent and the interruption was spurious.
  4. Ensure the http client future/response is fully consumed or properly canceled to avoid blocked waits.

Example fix

// before
try (InputStream in = responseHandler.getStream()) {
  in.readAllBytes(); // IOException("Interrupted!") propagates raw
} catch (IOException e) {
  throw new RuntimeException(e); // loses interrupt semantics
}
// after
try (InputStream in = responseHandler.getStream()) {
  in.readAllBytes();
} catch (InterruptedIOException e) {
  Thread.currentThread().interrupt();
  throw new QueryInterruptedException("Query cancelled");
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  stream.read(...);
} catch (IOException e) {
  if (Thread.currentThread().isInterrupted()) {
    throw new QueryInterruptedException("Query cancelled"); // treat as cancellation
  }
  throw e;
}

Prevention

When it happens

Trigger: A thread blocked in read()/skip() waiting for more bytes when another thread interrupts it — typically caller cancellation, executor shutdown, or a request timeout canceling the future and interrupting the reading thread.

Common situations: Druid query cancellation interrupting the thread pulling an HTTP response body; segment loading or task threads being interrupted on shutdown; timeouts that interrupt in-flight response consumption.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


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

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/java/util/http/client/io/AppendableByteArrayInputStream.java:146

  {
    long numScanned = 0;
    long numPulled = 0;

    while (numToScan > numScanned) {
      if (currIndex >= curr.length) {
        synchronized (singleByteReaderDoer) {
          if (bytes.isEmpty()) {
            if (done) {
              break;
            }
            try {
              available -= numPulled;
              numPulled = 0;
              singleByteReaderDoer.wait();
            }
            catch (InterruptedException e) {
              Thread.currentThread().interrupt();
              throw new IOException("Interrupted!");
            }
          }

          if (throwable != null) {
            throw new IOException(throwable);
          }

          if (bytes.isEmpty()) {
            if (done) {
              break;
            } else {
              log.debug("bytes was empty, but read thread was awakened without being done.  This shouldn't happen.");
              continue;
            }
          }

          curr = bytes.removeFirst();
          currIndex = 0;

View on GitHub (pinned to 9b90983fd2)