{"record":{"id":"b05d519088495772","repo":"apache/hadoop","slug":"incorrect-data-format-rename-operation","errorCode":null,"errorMessage":"Incorrect data format. Rename operation.","messagePattern":"Incorrect data format\\. Rename 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":2741,"sourceCode":"\n    @Override\n    public \n    void writeFields(DataOutputStream out) throws IOException {\n      FSImageSerialization.writeString(src, out);\n      FSImageSerialization.writeString(dst, out);\n      FSImageSerialization.writeLong(timestamp, out);\n      toBytesWritable(options).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 != 3) {\n          throw new IOException(\"Incorrect data format. \" + \"Rename operation.\");\n        }\n      }\n      this.src = FSImageSerialization.readString(in);\n      this.dst = FSImageSerialization.readString(in);\n\n      if (NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {\n        this.timestamp = FSImageSerialization.readLong(in);\n      } else {\n        this.timestamp = readLong(in);\n      }\n      this.options = readRenameOptions(in);\n      \n      // read RPC ids if necessary\n      readRpcIds(in, logVersion);\n    }\n\n    private static Rename[] readRenameOptions(DataInputStream in) throws IOException {","sourceCodeStart":2723,"sourceCodeEnd":2759,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L2723-L2759","documentation":"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.","triggerScenarios":"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.","commonSituations":"Crash-torn edits on unclean shutdown; failing journal/name disks; archived legacy segments with damage.","solutions":["Run 'hdfs namenode -recover' to skip the bad edit and continue replay","Confirm the damage point with 'hdfs offlineEditsViewer'","Restore an undamaged copy of the segment or roll back to the previous checkpoint"],"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(\"Rename operation\")) {\n    // corrupt legacy OP_RENAME record: skip via 'hdfs namenode -recover' or restore clean copy\n  } else { throw e; }\n}","preventionTips":["Clean shutdowns, healthy journal storage, regular checkpoints","Validate edits after crashes with offlineEditsViewer before restart"],"tags":["hdfs","edit-log","corruption","rename","legacy-format"],"backgroundTag":"edit-log-corruption","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}