apache/hadoop · error · IOException

Event schema string not parsed since its null

Error message

Event schema string not parsed since its null

What it means

A job history file's second line carries the Avro schema EventWriter emits after the version line. If EventReader reads null for that line the stream ended prematurely, and it throws IOException("Event schema string not parsed since its null"): the file is empty or truncated before the header was flushed, so no events can ever be decoded from it.

Source

Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapreduce/jobhistory/EventReader.java:88

    Schema myschema = new SpecificData(Event.class.getClassLoader()).getSchema(Event.class);
    Schema.Parser parser = new Schema.Parser();
    String eventschema = in.readLine();
    if (null != eventschema) {
      try {
        this.schema = parser.parse(eventschema);
        this.reader = new SpecificDatumReader(schema, myschema);
        if (EventWriter.VERSION.equals(version)) {
          this.decoder = DecoderFactory.get().jsonDecoder(schema, in);
        } else if (EventWriter.VERSION_BINARY.equals(version)) {
          this.decoder = DecoderFactory.get().binaryDecoder(in, null);
        } else {
          throw new IOException("Incompatible event log version: " + version);
        }
      } catch (AvroRuntimeException e) {
        throw new IOException(e);
      }
    } else {
      throw new IOException("Event schema string not parsed since its null");
    }
  }
  
  /**
   * Get the next event from the stream
   * @return the next event
   * @throws IOException
   */
  @SuppressWarnings("unchecked")
  public HistoryEvent getNextEvent() throws IOException {
    Event wrapper;
    try {
      wrapper = (Event)reader.read(null, decoder);
    } catch (EOFException e) {            // at EOF
      return null;
    }
    HistoryEvent result;
    switch (wrapper.getType()) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Pre-check the file: skip files of length 0 or whose first two lines cannot be read.
  2. For finished jobs, consume files from the done/ (completed) history directory rather than the intermediate one.
  3. Regenerate history by re-running the job if the record is required and the file is unrecoverable.
  4. Verify HDFS file integrity (hdfs fsck) if truncation is unexpected.

Example fix

// before
EventReader reader = new EventReader(fs.open(historyPath)); // IOException on empty file

// after
FileStatus st = fs.getFileStatus(historyPath);
if (st.getLen() == 0) {
  LOG.warn("Skipping empty history file " + historyPath);
  continue;
}
EventReader reader = new EventReader(fs.open(historyPath));
Defensive patterns

Strategy: validation

Validate before calling

FileStatus st = fs.getFileStatus(path);
if (st.getLen() == 0) {
  // empty history stub (aborted job) - skip
}

Try / catch

catch (IOException e) with message "Event schema string not parsed": treat the file as truncated/empty, skip it, and continue the scan - no retry can help.

Prevention

When it happens

Trigger: new EventReader(in) on a 0-byte file, a file containing only the version line, or a .jhist truncated at the very start - typically a history file from a job that was killed/crashed before the writer flushed, or an HDFS file with missing blocks.

Common situations: History scanning tools globbing intermediatedone/ picking up in-progress or aborted files; manually copied/truncated history files; jobs killed immediately after submission leaving stub .jhist files.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/c3b5a7bbf4d12262. Report an issue: GitHub.