{"record":{"id":"7bddd10c51bed878","repo":"apache/druid","slug":"interrupted","errorCode":null,"errorMessage":"interrupted","messagePattern":"interrupted","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/frame/channel/ReadableInputStreamFrameChannel.java","lineNumber":191,"sourceCode":"      while (true) {\n        if (!keepReading) {\n          try {\n            synchronized (readMonitor) {\n              if (!keepReading) {\n                readMonitor.wait(nextRetrySleepMillis(nTry));\n              }\n            }\n            synchronized (lock) {\n              if (inputStreamFinished || inputStreamError || delegate.isErrorOrFinished()) {\n                return;\n              }\n            }\n            ++nTry;\n          }\n          catch (InterruptedException e) {\n            // close input stream anyway if the thread interrupts\n            IOUtils.closeQuietly(inputStream);\n            throw new ISE(e, Thread.currentThread().getName() + \"interrupted\");\n          }\n\n        } else {\n          synchronized (lock) {\n            nTry = 1; // Reset the value of try because we are not waiting on the data from the inputStream\n            // if done reading method is called we should not read input stream further\n            if (inputStreamFinished) {\n              delegate.doneWriting();\n              break;\n            }\n            try {\n\n              int bytesRead = inputStream.read(buffer);\n              if (bytesRead == -1) {\n                inputStreamFinished = true;\n                delegate.doneWriting();\n                // eagerly release input stream resources since everything is read.\n                IOUtils.closeQuietly(inputStream);","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/frame/channel/ReadableInputStreamFrameChannel.java#L173-L209","documentation":"ReadableInputStreamFrameChannel reads frames from an InputStream on a background thread. If the reading thread is interrupted while blocking on the input stream, the channel quietly closes the stream and throws ISE wrapping the InterruptedException with the thread name plus 'interrupted'. It signals that blocking I/O was cancelled mid-read.","triggerScenarios":"Calling startReading() (triggered via isFinished, canRead, read, or readabilityFuture) and the worker thread is interrupted while waiting for bytes on the underlying InputStream — e.g. during query cancellation or executor shutdown.","commonSituations":"Query cancellation in the MSQ/clustered engine interrupts task threads; shutting down a Druid service while a frame transfer is in flight; misconfigured thread pools that interrupt idle workers.","solutions":["Check whether the interruption was an intentional cancellation (query killed/shutdown); if so, treat it as expected and propagate/ignore.","If not intentional, audit thread-pool configuration and code paths that call Future.cancel(true) or Thread.interrupt().","Ensure the channel is closed in a finally block so resources are released after the ISE.","Retry the transfer on a fresh channel if the interrupt was spurious."],"exampleFix":"// before\nRowsAndColumns rac = channel.read(); // ISE ...interrupted on cancel\n// after\ntry {\n  RowsAndColumns rac = channel.read();\n} catch (IllegalStateException e) {\n  if (e.getCause() instanceof InterruptedException && cancellationToken.isCancelled()) {\n    return; // expected cancellation\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) { /* resolve interruption before starting reads */ }","typeGuard":null,"tryCatchPattern":"try { channel.read(); } catch (IllegalStateException e) { if (e.getCause() instanceof InterruptedException) { /* handle cancellation or restore interrupt: Thread.currentThread().interrupt(); */ } else throw e; }","preventionTips":["Check cancellation status before long frame transfers","Always close channels in finally blocks","Avoid interrupting worker threads for non-cancellation reasons"],"tags":["interruption","threads","stream-io"],"backgroundTag":"request-timeout","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"}