{"record":{"id":"61a5c72926211f29","repo":"apache/hadoop","slug":"incorrect-data-format-concatdeleteop-cannot-have","errorCode":null,"errorMessage":"Incorrect data format. ConcatDeleteOp cannot have a negative number of data  sources.","messagePattern":"Incorrect data format\\. ConcatDeleteOp cannot have a negative number of data  sources\\.","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":1325,"sourceCode":"        throws IOException {\n      if (!NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {\n        this.length = in.readInt();\n        if (length < 3) { // trg, srcs.., timestamp\n          throw new IOException(\"Incorrect data format \" +\n              \"for ConcatDeleteOp.\");\n        }\n      }\n      this.trg = FSImageSerialization.readString(in);\n      int srcSize = 0;\n      if (NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.EDITLOG_OP_OPTIMIZATION, logVersion)) {\n        srcSize = in.readInt();\n      } else {\n        srcSize = this.length - 1 - 1; // trg and timestamp\n      }\n      if (srcSize < 0) {\n          throw new IOException(\"Incorrect data format. \"\n              + \"ConcatDeleteOp cannot have a negative number of data \" +\n              \" sources.\");\n      } else if (srcSize > MAX_CONCAT_SRC) {\n          throw new IOException(\"Incorrect data format. \"\n              + \"ConcatDeleteOp can have at most \" + MAX_CONCAT_SRC +\n              \" sources, but we tried to have \" + (length - 3) + \" sources.\");\n      }\n      this.srcs = new String [srcSize];\n      for(int i=0; i<srcSize;i++) {\n        srcs[i]= FSImageSerialization.readString(in);\n      }\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      }","sourceCodeStart":1307,"sourceCodeEnd":1343,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSEditLogOp.java#L1307-L1343","documentation":"ConcatDeleteOp.readFields() derives the number of source paths (srcSize): in optimized layouts it is a 4-byte int read from the stream, in legacy layouts length-2. A negative srcSize cannot describe any record, so it is rejected as malformed data before allocating the sources array.","triggerScenarios":"A corrupt int where srcSize is read (bit rot, garbage after misalignment), or a legacy record whose length word was 0 or 1 so length-2 goes negative; typically follows an earlier truncated/misparsed record that shifted the stream position.","commonSituations":"Same family as the other legacy length checks: crash-torn writes, failing journal disk, segments read with the wrong layout version.","solutions":["Run 'hdfs namenode -recover' to skip the bad record and finish startup, then save a checkpoint","Inspect with 'hdfs offlineEditsViewer' to confirm the txid and extent of damage","Replace the segment from a healthy JournalNode copy or the last checkpoint + valid edits"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"hdfs offlineEditsViewer -i <edits segment> -o /dev/null   # fails at the first malformed record","typeGuard":null,"tryCatchPattern":"try {\n  reader.readOp();\n} catch (IOException e) {\n  LOG.error(\"Malformed concat record in \" + segment + \" at txid \" + reader.getLastTxId(), e);\n  // retry the whole replay with 'hdfs namenode -recover' (skipBrokenEdits)\n}","preventionTips":["Same as other edit-log corruption: QJM quorum, healthy disks, frequent checkpoints","Validate segments with offlineEditsViewer after crashes before restart","Avoid single-journal configurations where the only copy can silently rot"],"tags":["hdfs","edit-log","corruption","legacy-format"],"backgroundTag":"edit-log-corruption","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}