{"record":{"id":"95add0ed54cab6c0","repo":"apache/hadoop","slug":"incorrect-data-format-symlink-operation","errorCode":null,"errorMessage":"Incorrect data format. symlink operation.","messagePattern":"Incorrect data format\\. symlink operation\\.","errorType":"exception","errorClass":"java.io.IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java","lineNumber":2595,"sourceCode":"    @Override\n    public void writeFields(DataOutputStream out) throws IOException {\n      FSImageSerialization.writeLong(inodeId, out);      \n      FSImageSerialization.writeString(path, out);\n      FSImageSerialization.writeString(value, out);\n      FSImageSerialization.writeLong(mtime, out);\n      FSImageSerialization.writeLong(atime, out);\n      permissionStatus.write(out);\n      writeRpcIds(rpcClientId, rpcCallId, out);\n    }\n\n    @Override\n    void readFields(DataInputStream in, int logVersion)\n        throws IOException {\n      if (!NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {\n        this.length = in.readInt();\n        if (this.length != 4) {\n          throw new IOException(\"Incorrect data format. \"\n              + \"symlink operation.\");\n        }\n      }\n      if (NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.ADD_INODE_ID, logVersion)) {\n        this.inodeId = FSImageSerialization.readLong(in);\n      } else {\n        // This id should be updated when the editLogOp is applied\n        this.inodeId = HdfsConstants.GRANDFATHER_INODE_ID;\n      }\n      this.path = FSImageSerialization.readString(in);\n      this.value = FSImageSerialization.readString(in);\n\n      if (NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {\n        this.mtime = FSImageSerialization.readLong(in);\n        this.atime = FSImageSerialization.readLong(in);\n      } else {","sourceCodeStart":2577,"sourceCodeEnd":2613,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L2577-L2613","documentation":"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.","triggerScenarios":"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.","commonSituations":"Older clusters with symlinks enabled hit by disk corruption or torn writes; mixed layout-version segments after botched upgrades.","solutions":["Run 'hdfs namenode -recover' to skip the record","Use 'hdfs offlineEditsViewer' to identify the corrupt txid and what is lost","Restore the segment from an intact copy (QJM majority / checkpoint) if the damage is more than one record"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"hdfs offlineEditsViewer -i <edits segment> -o /dev/null","typeGuard":null,"tryCatchPattern":"try {\n  reader.readOp();\n} catch (IOException e) {\n  if (e.getMessage().contains(\"symlink operation\")) {\n    // corrupt legacy OP_SYMLINK record: skip with 'hdfs namenode -recover' or restore clean copy\n  } else { throw e; }\n}","preventionTips":["Legacy segments with symlinks are old by definition: migrate them to checkpoints early","Keep verified backups; validate archived segments before replay"],"tags":["hdfs","edit-log","corruption","symlink","legacy-format"],"backgroundTag":"edit-log-corruption","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}