{"record":{"id":"aafa0c8d63f89c08","repo":"apache/hadoop","slug":"incorrect-data-format-delete-operation","errorCode":null,"errorMessage":"Incorrect data format. delete operation.","messagePattern":"Incorrect data format\\. delete 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":1562,"sourceCode":"      return this;\n    }\n\n    @Override\n    public \n    void writeFields(DataOutputStream out) throws IOException {\n      FSImageSerialization.writeString(path, 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 != 2) {\n          throw new IOException(\"Incorrect data format. \" + \"delete operation.\");\n        }\n      }\n      this.path = 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      // read RPC ids if necessary\n      readRpcIds(in, logVersion);\n    }\n\n    @Override\n    public String toString() {\n      StringBuilder builder = new StringBuilder();\n      builder.append(\"DeleteOp [length=\")\n          .append(length)","sourceCodeStart":1544,"sourceCodeEnd":1580,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L1544-L1580","documentation":"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.","triggerScenarios":"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.","commonSituations":"Crash mid-write leaving a partial OP_DELETE record; failing disks; segments from mixed Hadoop versions in one name dir.","solutions":["Run 'hdfs namenode -recover' and answer yes to skip the damaged edit","Confirm the extent of damage with 'hdfs offlineEditsViewer'","Fall back to the last fsimage checkpoint or a healthy journal copy"],"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(\"delete operation\")) {\n    // corrupt OP_DELETE record: skip via 'hdfs namenode -recover' or restore clean copy\n  } else { throw e; }\n}","preventionTips":["Unclean shutdowns are the usual producer: always stop the NameNode cleanly","Keep journal disks healthy and monitored","Take checkpoints so replay of old segments is short"],"tags":["hdfs","edit-log","corruption","delete","legacy-format"],"backgroundTag":"edit-log-corruption","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}