apache/hadoop · error · java.io.IOException

Incorrect data format. times operation.

Error message

Incorrect data format. times operation.

What it means

TimesOp.readFields() (OP_TIMES, setTimes()): in legacy layouts without EDITLOG_OP_OPTIMIZATION the record's length word must be exactly 3 (path, mtime, atime). Any other value aborts the parse as malformed data.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java:2465

      return this;
    }

    @Override
    public 
    void writeFields(DataOutputStream out) throws IOException {
      FSImageSerialization.writeString(path, out);
      FSImageSerialization.writeLong(mtime, out);
      FSImageSerialization.writeLong(atime, out);
    }

    @Override
    void readFields(DataInputStream in, int logVersion)
        throws IOException {
      if (!NameNodeLayoutVersion.supports(
          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {
        this.length = in.readInt();
        if (length != 3) {
          throw new IOException("Incorrect data format. " + "times operation.");
        }
      }
      this.path = FSImageSerialization.readString(in);

      if (NameNodeLayoutVersion.supports(
          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {
        this.mtime = FSImageSerialization.readLong(in);
        this.atime = FSImageSerialization.readLong(in);
      } else {
        this.mtime = readLong(in);
        this.atime = readLong(in);
      }
    }

    @Override
    public String toString() {
      StringBuilder builder = new StringBuilder();
      builder.append("TimesOp [length=")

View on GitHub (pinned to 2add963021)

Solutions

  1. Run 'hdfs namenode -recover' to skip the damaged record, then checkpoint
  2. Pinpoint the failure with 'hdfs offlineEditsViewer -i <edits> -o out.xml'
  3. Restore from a healthy journal copy or the last fsimage if too many records must be skipped
Defensive patterns

Strategy: try-catch

Validate before calling

hdfs offlineEditsViewer -i <edits segment> -o /dev/null

Try / catch

try {
  reader.readOp();
} catch (IOException e) {
  if (e.getMessage().contains("times operation")) {
    // corrupt OP_TIMES record: recover via 'hdfs namenode -recover' or clean journal copy
  } else { throw e; }
}

Prevention

When it happens

Trigger: Corrupt length int at the start of an OP_TIMES record, or a misaligned stream after earlier truncation; reading a non-edits file.

Common situations: Crash-torn records on restart; unhealthy journal storage; mixed-version segments.

Related errors


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