{"record":{"id":"66ddce67f8207ce2","repo":"apache/beam","slug":"could-not-read-because-the-thread-got-interrupted-while","errorCode":null,"errorMessage":"Could not read because the thread got interrupted while reading the records with an exception: ","messagePattern":"Could not read because the thread got interrupted while reading the records with an exception: ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java","lineNumber":941,"sourceCode":"        try {\n          recordsReturned.set(0L);\n          recordReader = inputFormatObj.createRecordReader(split.getSplit(), taskAttemptContext);\n          if (recordReader != null) {\n            recordReader.initialize(split.getSplit(), taskAttemptContext);\n            progressValue.set(getProgress());\n            if (recordReader.nextKeyValue()) {\n              recordsReturned.incrementAndGet();\n              doneReading = false;\n              return true;\n            }\n          } else {\n            throw new IOException(\n                String.format(\n                    \"Null RecordReader object returned by %s\", inputFormatObj.getClass()));\n          }\n          recordReader = null;\n        } catch (InterruptedException e) {\n          throw new IOException(\n              \"Could not read because the thread got interrupted while \"\n                  + \"reading the records with an exception: \",\n              e);\n        }\n        doneReading = true;\n        return false;\n      }\n\n      @Override\n      public boolean advance() throws IOException {\n        try {\n          progressValue.set(getProgress());\n          if (recordReader.nextKeyValue()) {\n            recordsReturned.incrementAndGet();\n            return true;\n          }\n          doneReading = true;\n        } catch (InterruptedException e) {","sourceCodeStart":923,"sourceCodeEnd":959,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hadoop-format/src/main/java/org/apache/beam/sdk/io/hadoop/format/HadoopFormatIO.java#L923-L959","documentation":"While the reader advances records with RecordReader.nextKeyValue(), an InterruptedException means the executing thread was interrupted (e.g., cancellation or runner shutdown). HadoopFormatIO converts it into this IOException, chaining the interrupt cause.","triggerScenarios":"Pipeline cancellation, job deadline exceeded, or runner shutdown while HadoopInputFormatReader.advance() is blocked inside nextKeyValue().","commonSituations":"Users canceling a running Beam pipeline; wall-clock timeouts in Dataflow/Flink causing task cancellation; long-blocking record readers being interrupted by the runner.","solutions":["Rerun the pipeline if interruption was due to cancellation or shutdown","Investigate why the runner interrupted the task (timeout, OOM kill, autoscaling)","Reduce per-record blocking in the custom RecordReader so interruption lands in a safe state"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  reader.advance();\n} catch (IOException e) {\n  if (e.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt(); // restore interrupt flag\n    return; // graceful shutdown\n  }\n  throw e;\n}","preventionTips":["Avoid wall-clock timeouts that preempt long readers","Keep RecordReader.nextKeyValue() free of indefinite blocking","Restore the interrupt flag when handling InterruptedException in custom readers"],"tags":["hadoop","interrupted","threading","reader"],"backgroundTag":"thread-interrupted","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}