{"record":{"id":"87379ed60a39627d","repo":"apache/hadoop","slug":"incorrect-data-format-old-rename-operation","errorCode":null,"errorMessage":"Incorrect data format. Old rename operation.","messagePattern":"Incorrect data format\\. Old rename operation\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java","lineNumber":1457,"sourceCode":"    }\n\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      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. \"\n              + \"Old rename operation.\");\n        }\n      }\n      this.src = FSImageSerialization.readString(in);\n      this.dst = FSImageSerialization.readString(in);\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      \n      // read RPC ids if necessary\n      readRpcIds(in, logVersion);\n    }\n\n    @Override\n    public String toString() {","sourceCodeStart":1439,"sourceCodeEnd":1475,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L1439-L1475","documentation":"RenameOldOp.readFields() (the pre-options rename record): in legacy layouts without EDITLOG_OP_OPTIMIZATION the record's length word must be exactly 3 (src, dst, timestamp). Any other value means the record is malformed or the stream is misaligned, and the parse fails before reading the paths.","triggerScenarios":"Replaying an old-format edits segment where the length word is corrupt, or where earlier corruption shifted the stream so a body integer is interpreted as the length; also parsing a file that is not an edit log.","commonSituations":"Old upgrades replaying legacy segments; crash-torn records; damaged name/journal disks.","solutions":["Run 'hdfs namenode -recover' to skip past the record","Locate the failing txid via 'hdfs offlineEditsViewer' and assess what transaction is lost","Restore the good copy of the segment from QJM majority / SecondaryNameNode, or restart from the last checkpoint"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"hdfs offlineEditsViewer -i <legacy edits segment> -o /dev/null","typeGuard":null,"tryCatchPattern":"try {\n  reader.readOp(); // replaying legacy rename records\n} catch (IOException e) {\n  // length word != 3: legacy record is corrupt -> recover with 'hdfs namenode -recover'\n}","preventionTips":["Convert legacy logs to a checkpointed fsimage with the release that wrote them before upgrading","Keep pre-upgrade name dir backups","Validate archived legacy segments periodically; old media rots"],"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"}