{"record":{"id":"a034c5b481db2d5f","repo":"apache/hadoop","slug":"unexpected-eos-from-the-reader-a034c5","errorCode":null,"errorMessage":"Unexpected EOS from the reader","messagePattern":"Unexpected EOS from the reader","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/StripeReader.java","lineNumber":243,"sourceCode":"    for (int i = 0; i < strategies.length; i++) {\n      ByteBuffer buffer = chunk.getChunkBuffer().getSlice(i);\n      strategies[i] = new ByteBufferStrategy(buffer,\n              dfsStripedInputStream.getReadStatistics(),\n              dfsStripedInputStream.getDFSClient());\n    }\n    return strategies;\n  }\n\n  private int readToBuffer(BlockReader blockReader,\n      DatanodeInfo currentNode, ByteBufferStrategy strategy,\n      ExtendedBlock currentBlock) throws IOException {\n    final int targetLength = strategy.getTargetLength();\n    int length = 0;\n    try {\n      while (length < targetLength) {\n        int ret = strategy.readFromBlock(blockReader);\n        if (ret < 0) {\n          throw new IOException(\"Unexpected EOS from the reader\");\n        }\n        length += ret;\n      }\n      return length;\n    } catch (ChecksumException ce) {\n      DFSClient.LOG.warn(\"Found Checksum error for \"\n          + currentBlock + \" from \" + currentNode\n          + \" at \" + ce.getPos());\n      //Clear buffer to make next decode success\n      strategy.getReadBuffer().clear();\n      // we want to remember which block replicas we have tried\n      corruptedBlocks.addCorruptedBlock(currentBlock, currentNode);\n      if (blockReader != null) {\n        blockReader.close();\n      }\n      throw ce;\n    } catch (IOException e) {\n      DFSClient.LOG.warn(\"Exception while reading from \"","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/StripeReader.java#L225-L261","documentation":"In StripeReader.readToBuffer, data is read from a BlockReader until strategy's target length is satisfied; a negative return from readFromBlock means end-of-stream before targetLength bytes arrived, which is unexpected because the reader was positioned and sized for exactly this chunk. It signals the DataNode closed the connection early — node crash/restart mid-read, truncated or corrupted chunk, or reader/protobuf state corruption — rather than a clean short read.","triggerScenarios":"Erasure-coded read where a DataNode serving one chunk dies or resets the connection mid-transfer; block/chunk length on the DataNode shorter than the LocatedStripedBlock metadata claims; transient network device drops during large striped reads.","commonSituations":"DataNode OOM/restart under load while an EC job reads; network appliances idle-resetting long-lived DataNode connections; rare corruption cases where on-disk chunk size disagrees with block metadata; seen more during heavy parallel scan jobs over EC data.","solutions":["Retry the read/job — DFSClient striped reads attempt other chunks/replicas, and transient node failures typically clear","Check DataNode logs around the failure time for OOM, disk errors, or restarts on the hosts named in preceding warnings","Run hdfs fsck on the file to rule out truncated/corrupted chunks if the error persists on the same offset","Keep client and DataNode Hadoop versions current — several premature-EOS bugs in striped reads were fixed in later 3.x patch releases"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  readFully(in, buf, off, len);\n} catch (IOException e) {\n  if (e.getMessage().equals(\"Unexpected EOS from the reader\")) {\n    // DataNode dropped mid-chunk; reopen, re-locate, and retry the range\n    reopenAt(offset); // DFSClient retries other replicas on next read\n  } else throw e;\n}","preventionTips":["Retry reads that fail mid-stream; striped readers re-fetch the failed chunk from another source on reopen","Watch DataNode GC/OOM/disk metrics — premature EOS usually traces to node-side faults","Keep Hadoop patch levels current; several striped-read EOS bugs were fixed in later 3.x releases"],"tags":["hdfs","erasure-coding","premature-eof","datanode","network"],"backgroundTag":"unexpected-eof","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}