{"record":{"id":"c0df68055e75afff","repo":"apache/hadoop","slug":"unexpected-version-of-the-file-system-log-file-lo","errorCode":null,"errorMessage":"Unexpected version of the file system log file: logVersion. Current version = HdfsServerConstants.NAMENODE_LAYOUT_VERSION.","messagePattern":"Unexpected version of the file system log file: logVersion\\. Current version = HdfsServerConstants\\.NAMENODE_LAYOUT_VERSION\\.","errorType":"exception","errorClass":"LogHeaderCorruptException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileInputStream.java","lineNumber":388,"sourceCode":"   * Read the header of fsedit log\n   * @param in fsedit stream\n   * @return the edit log version number\n   * @throws IOException if error occurs\n   */\n  @VisibleForTesting\n  static int readLogVersion(DataInputStream in, boolean verifyLayoutVersion)\n      throws IOException, LogHeaderCorruptException {\n    int logVersion;\n    try {\n      logVersion = in.readInt();\n    } catch (EOFException eofe) {\n      throw new LogHeaderCorruptException(\n          \"Reached EOF when reading log header\");\n    }\n    if (verifyLayoutVersion &&\n        (logVersion < HdfsServerConstants.NAMENODE_LAYOUT_VERSION || // future version\n         logVersion > Storage.LAST_UPGRADABLE_LAYOUT_VERSION)) { // unsupported\n      throw new LogHeaderCorruptException(\n          \"Unexpected version of the file system log file: \"\n          + logVersion + \". Current version = \"\n          + HdfsServerConstants.NAMENODE_LAYOUT_VERSION + \".\");\n    }\n    return logVersion;\n  }\n  \n  /**\n   * Exception indicating that the header of an edits log file is\n   * corrupted. This can be because the header is not present,\n   * or because the header data is invalid (eg claims to be\n   * over a newer version than the running NameNode)\n   */\n  static class LogHeaderCorruptException extends IOException {\n    private static final long serialVersionUID = 1L;\n\n    private LogHeaderCorruptException(String msg) {\n      super(msg);","sourceCodeStart":370,"sourceCodeEnd":406,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/EditLogFileInputStream.java#L370-L406","documentation":"LogHeaderCorruptException('Unexpected version of the file system log file: <v>') from readLogVersion() when verifyLayoutVersion is on and the layout version is out of range: logVersion < NAMENODE_LAYOUT_VERSION means the edits were written by a NEWER Hadoop release (layout versions grow more negative over time), and logVersion > Storage.LAST_UPGRADABLE_LAYOUT_VERSION means a release so old this NameNode can no longer upgrade it. Either way this binary refuses to replay the log.","triggerScenarios":"Starting older binaries against a name dir whose edits were already written by a newer release (accidental downgrade, or an HA pair with mixed versions where the stale node reads new-layout edits); replaying edits copied from a newer cluster; restoring an ancient name dir beyond LAST_UPGRADABLE_LAYOUT_VERSION.","commonSituations":"Downgrade attempted after a layout upgrade was finalized; rolling upgrade where one NN upgraded and wrote new-layout edits while the other stayed old; mixing cluster versions while copying journals; test clusters swapping Hadoop versions on the same name dir.","solutions":["If this was an unintended downgrade, restart on the newer release that wrote the edits.","For rolling-upgrade rollback, use the documented rollback path (hdfs namenode -rollingUpgrade rollback) which restores pre-upgrade dirs, instead of booting old binaries on the new layout.","If the edits are genuinely too old, replay them with the intermediate supported release, or skip replay: build a fresh image via hdfs namenode -importCheckpoint from a newer checkpoint.","In HA, never let NNs of different major versions share a journal; finish the rolling upgrade before the other NN reads the new layout."],"exampleFix":"# before: started hadoop-2.8 binaries on a name dir written by 3.1\n# -> 'Unexpected version of the file system log file: -66 ...'\n# after: restart the NN with the original newer release\n<deploy hadoop-3.1>/bin/hdfs namenode   # layout matches, edits replay fine","handlingStrategy":"try-catch","validationCode":"int v = new DataInputStream(new BufferedInputStream(\n    Files.newInputStream(editsFile))).readInt();\nif (v < HdfsServerConstants.NAMENODE_LAYOUT_VERSION) {\n  // edits written by a NEWER release; this binary must not replay them\n}","typeGuard":null,"tryCatchPattern":"try {\n  int v = EditLogFileInputStream.readLogVersion(in, /*verify*/ true);\n} catch (EditLogFileInputStream.LogHeaderCorruptException e) {\n  if (e.getMessage().startsWith(\"Unexpected version\")) {\n    // stop immediately: wrong Hadoop version for this journal; boot the matching release\n  } else { throw e; }\n}","preventionTips":["In HA and rolling upgrades, never let an un-upgraded NN read a journal written by a newer layout version.","Downgrade only via documented rollback (hdfs namenode -rollingUpgrade rollback), never by booting old binaries on upgraded dirs.","Record the Hadoop version alongside archived name dirs; verify layout compatibility before replaying.","When copying journals across clusters, ensure both run the same release."],"tags":["hdfs","edit-log","layout-version","downgrade","upgrade"],"backgroundTag":"layout-version-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}