apache/hadoop · error · IOException

Incorrect data format. delete operation.

Error message

Incorrect data format. delete operation.

What it means

DeleteOp.readFields(): in legacy layouts without EDITLOG_OP_OPTIMIZATION the record starts with a length word that must be exactly 2 (path, timestamp). A different value means the bytes are not a well-formed delete record, so the reader refuses to continue.

Source

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

      return this;
    }

    @Override
    public 
    void writeFields(DataOutputStream out) throws IOException {
      FSImageSerialization.writeString(path, out);
      FSImageSerialization.writeLong(timestamp, 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 != 2) {
          throw new IOException("Incorrect data format. " + "delete operation.");
        }
      }
      this.path = FSImageSerialization.readString(in);
      if (NameNodeLayoutVersion.supports(
          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {
        this.timestamp = FSImageSerialization.readLong(in);
      } else {
        this.timestamp = readLong(in);
      }
      // read RPC ids if necessary
      readRpcIds(in, logVersion);
    }

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

View on GitHub (pinned to 2add963021)

Solutions

  1. Run 'hdfs namenode -recover' and answer yes to skip the damaged edit
  2. Confirm the extent of damage with 'hdfs offlineEditsViewer'
  3. Fall back to the last fsimage checkpoint or a healthy journal copy
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("delete operation")) {
    // corrupt OP_DELETE record: skip via 'hdfs namenode -recover' or restore clean copy
  } else { throw e; }
}

Prevention

When it happens

Trigger: A corrupt length int at the head of a delete record, or a misaligned stream after an earlier truncated record; parsing non-edits data as an edit log.

Common situations: Crash mid-write leaving a partial OP_DELETE record; failing disks; segments from mixed Hadoop versions in one name dir.

Related errors


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