{"record":{"id":"ca3adc0278fd9b9a","repo":"apache/hadoop","slug":"no-header-present-in-log-value-is-1-probably-d","errorCode":null,"errorMessage":"No header present in log (value is -1), probably due to disk space issues when it was created. The log has no transactions and will be sidelined.","messagePattern":"No header present in log \\(value is -1\\), probably due to disk space issues when it was created\\. The log has no transactions and will be sidelined\\.","errorType":"exception","errorClass":"LogHeaderCorruptException","httpStatus":null,"severity":"warning","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileInputStream.java","lineNumber":172,"sourceCode":"    BufferedInputStream bin = null;\n    InputStream fStream = null;\n    try {\n      fStream = log.getInputStream();\n      bin = new BufferedInputStream(fStream);\n      tracker = new FSEditLogLoader.PositionTrackingInputStream(bin);\n      dataIn = new DataInputStream(tracker);\n      try {\n        logVersion = readLogVersion(dataIn, verifyLayoutVersion);\n      } catch (EOFException eofe) {\n        throw new LogHeaderCorruptException(\"No header found in log\");\n      }\n      if (logVersion == -1) {\n        // The edits in progress file is pre-allocated with 1MB of \"-1\" bytes\n        // when it is created, then the header is written. If the header is\n        // -1, it indicates the an exception occurred pre-allocating the file\n        // and the header was never written. Therefore this is effectively a\n        // corrupt and empty log.\n        throw new LogHeaderCorruptException(\"No header present in log (value \" +\n            \"is -1), probably due to disk space issues when it was created. \" +\n            \"The log has no transactions and will be sidelined.\");\n      }\n      // We assume future layout will also support ADD_LAYOUT_FLAGS\n      if (NameNodeLayoutVersion.supports(\n          LayoutVersion.Feature.ADD_LAYOUT_FLAGS, logVersion) ||\n          logVersion < NameNodeLayoutVersion.CURRENT_LAYOUT_VERSION) {\n        try {\n          LayoutFlags.read(dataIn);\n        } catch (EOFException eofe) {\n          throw new LogHeaderCorruptException(\"EOF while reading layout \" +\n              \"flags from log\");\n        }\n      }\n      reader = FSEditLogOp.Reader.create(dataIn, tracker, logVersion);\n      reader.setMaxOpSize(maxOpSize);\n      state = State.OPEN;\n    } finally {","sourceCodeStart":154,"sourceCodeEnd":190,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileInputStream.java#L154-L190","documentation":"LogHeaderCorruptException thrown when the first int read from an edit log is -1 (0xFFFFFFFF). edits_in_progress files are pre-allocated with 1MB of -1 bytes before the real header overwrites them; reading -1 means the header was never written (an exception, classically disk full, interrupted the pre-allocation), so the segment is effectively empty and is sidelined. This is benign by design: the log has no transactions.","triggerScenarios":"Loading or validating an edits_in_progress_* segment whose creation failed after pre-allocation: disk full on the name/edit device at roll time, or a crash between preallocate and header write.","commonSituations":"Name-directory disk filling up (fsimage + retained edits); NN crash exactly during segment roll; repeated rolls failing on a full device leave several such files.","solutions":["Free space on the name/edit device, then restart (or run hdfs namenode -recover): the NN sidelines the empty segment automatically.","If startup still loops, move the offending edits_in_progress_* aside; it contains no transactions.","Long term: alert on name-dir usage and move dfs.namenode.edits.dir (or QJM) off the full device."],"exampleFix":"# before: 'No header present in log (value is -1)' at NN start after disk-full event\ndf -h /dfs/nn && rm -f /dfs/nn/current/edits_in_progress_*unused*\nhdfs namenode -recover\n# after: empty segment sidelined, NN starts clean","handlingStrategy":"try-catch","validationCode":"int v = new DataInputStream(new BufferedInputStream(\n    Files.newInputStream(editsInProgress))).readInt();\nif (v == -1) {\n  // preallocated-but-never-written header: segment is empty, safe to sideline\n}","typeGuard":null,"tryCatchPattern":"catch (EditLogFileInputStream.LogHeaderCorruptException e) {\n  if (e.getMessage().contains(\"value is -1\")) {\n    // empty preallocated segment: free name-dir disk space and sideline; no transactions exist\n  } else { throw e; }\n}","preventionTips":["Alert on name/edit directory usage well before full -- the -1 header is the classic disk-full-at-roll signature.","Put dfs.namenode.edits.dir (or QJM) on a different device from fsimage storage.","Trust the NN's sidelining of empty segments; do not preemptively delete other segments."],"tags":["hdfs","edit-log","disk-full","preallocation","namenode-startup"],"backgroundTag":"edit-log-corruption","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}