apache/hadoop · error · java.io.IOException

Incorrect data format. Rename operation.

Error message

Incorrect data format. Rename operation.

What it means

RenameOp.readFields() (OP_RENAME, the variant with rename options): in legacy layouts without EDITLOG_OP_OPTIMIZATION the length word must be exactly 3 (src, dst, timestamp). Any other value is treated as a malformed record and stops the parse before the paths are read.

Source

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

    @Override
    public 
    void writeFields(DataOutputStream out) throws IOException {
      FSImageSerialization.writeString(src, out);
      FSImageSerialization.writeString(dst, out);
      FSImageSerialization.writeLong(timestamp, out);
      toBytesWritable(options).write(out);
      writeRpcIds(rpcClientId, rpcCallId, out);
    }

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

      if (NameNodeLayoutVersion.supports(
          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {
        this.timestamp = FSImageSerialization.readLong(in);
      } else {
        this.timestamp = readLong(in);
      }
      this.options = readRenameOptions(in);
      
      // read RPC ids if necessary
      readRpcIds(in, logVersion);
    }

    private static Rename[] readRenameOptions(DataInputStream in) throws IOException {

View on GitHub (pinned to 2add963021)

Solutions

  1. Run 'hdfs namenode -recover' to skip the bad edit and continue replay
  2. Confirm the damage point with 'hdfs offlineEditsViewer'
  3. Restore an undamaged copy of the segment or roll back to the previous checkpoint
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("Rename operation")) {
    // corrupt legacy OP_RENAME record: skip via 'hdfs namenode -recover' or restore clean copy
  } else { throw e; }
}

Prevention

When it happens

Trigger: Corrupt length int in a legacy rename record, or stream misalignment caused by an earlier truncated/misparsed record; feeding a non-edits file to the reader.

Common situations: Crash-torn edits on unclean shutdown; failing journal/name disks; archived legacy segments with damage.

Related errors


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