apache/hadoop · error · java.io.IOException

Incorrect data format. symlink operation.

Error message

Incorrect data format. symlink operation.

What it means

SymlinkOp.readFields() (OP_SYMLINK): in legacy layouts without EDITLOG_OP_OPTIMIZATION the record's length word must be exactly 4 (path, link target, timestamp, permission status). A different value means the record is corrupt or misaligned, and readFields fails before deserializing the link.

Source

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

    @Override
    public void writeFields(DataOutputStream out) throws IOException {
      FSImageSerialization.writeLong(inodeId, out);      
      FSImageSerialization.writeString(path, out);
      FSImageSerialization.writeString(value, out);
      FSImageSerialization.writeLong(mtime, out);
      FSImageSerialization.writeLong(atime, out);
      permissionStatus.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 != 4) {
          throw new IOException("Incorrect data format. "
              + "symlink operation.");
        }
      }
      if (NameNodeLayoutVersion.supports(
          LayoutVersion.Feature.ADD_INODE_ID, logVersion)) {
        this.inodeId = FSImageSerialization.readLong(in);
      } else {
        // This id should be updated when the editLogOp is applied
        this.inodeId = HdfsConstants.GRANDFATHER_INODE_ID;
      }
      this.path = FSImageSerialization.readString(in);
      this.value = FSImageSerialization.readString(in);

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

View on GitHub (pinned to 2add963021)

Solutions

  1. Run 'hdfs namenode -recover' to skip the record
  2. Use 'hdfs offlineEditsViewer' to identify the corrupt txid and what is lost
  3. Restore the segment from an intact copy (QJM majority / checkpoint) if the damage is more than one record
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("symlink operation")) {
    // corrupt legacy OP_SYMLINK record: skip with 'hdfs namenode -recover' or restore clean copy
  } else { throw e; }
}

Prevention

When it happens

Trigger: A corrupt length word at the head of a legacy symlink record, or the stream sitting at the wrong offset after earlier damage; parsing data that is not an edit log.

Common situations: Older clusters with symlinks enabled hit by disk corruption or torn writes; mixed layout-version segments after botched upgrades.

Related errors


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