{"record":{"id":"63caed5cc375d877","repo":"apache/hadoop","slug":"incompatible-version-for-state-expecting-state-ve","errorCode":null,"errorMessage":"Incompatible version for state: expecting state version {}, but loading version {}","messagePattern":"Incompatible version for state: expecting state version (.+?), but loading version (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/HistoryServerLeveldbStateStoreService.java","lineNumber":363,"sourceCode":"   * 2) Any incompatible change of state-store is a major upgrade, and any\n   *    compatible change of state-store is a minor upgrade.\n   * 3) Within a minor upgrade, say 1.1 to 1.2:\n   *    overwrite the version info and proceed as normal.\n   * 4) Within a major upgrade, say 1.2 to 2.0:\n   *    throw exception and indicate user to use a separate upgrade tool to\n   *    upgrade state or remove incompatible old state.\n   */\n  private void checkVersion() throws IOException {\n    Version loadedVersion = loadVersion();\n    LOG.info(\"Loaded state version info \" + loadedVersion);\n    if (loadedVersion.equals(getCurrentVersion())) {\n      return;\n    }\n    if (loadedVersion.isCompatibleTo(getCurrentVersion())) {\n      LOG.info(\"Storing state version info \" + getCurrentVersion());\n      storeVersion();\n    } else {\n      throw new IOException(\n        \"Incompatible version for state: expecting state version \"\n            + getCurrentVersion() + \", but loading version \" + loadedVersion);\n    }\n  }\n}\n","sourceCodeStart":345,"sourceCodeEnd":369,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/HistoryServerLeveldbStateStoreService.java#L345-L369","documentation":"The LevelDB store records a schema version row (DB_SCHEMA_VERSION_KEY) and compares it with the current code version at startup via checkVersion. Equal versions pass; compatible versions are silently upgraded by writing the new version; an incompatible version throws this IOException so the server refuses to run against state it cannot interpret. The loaded version is also logged as 'Loaded state version info' for comparison.","triggerScenarios":"Downgrading JHS to an older Hadoop whose state version is incompatible with the stored one; jumping across incompatible major versions; pointing mapreduce.jobhistory.recovery.store.leveldb.path at a database created by different code.","commonSituations":"Rollback after a failed upgrade; repurposing a state directory; version skew between nodes in mixed-version clusters.","solutions":["Run the Hadoop version compatible with the stored state (compare the logged loaded version with the expected one in the message).","If the stored token state is disposable, stop JHS and remove the LevelDB directory; it is recreated at the current version and clients re-authenticate.","Back up the directory before deleting it.","Plan upgrades through compatible intermediate versions instead of downgrading."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // JHS startup with existing leveldb state\n} catch (IOException e) {\n  if (e.getMessage().startsWith(\"Incompatible version for state\")) {\n    // run the matching Hadoop version, or stop JHS and remove the state dir to reinitialize\n  }\n}","preventionTips":["Back up the state directory before upgrades.","Do not downgrade JHS below the version that wrote the state.","After deliberate state wipes, expect clients to re-authenticate."],"tags":["mapreduce","leveldb","state-store","versioning","migration"],"backgroundTag":"schema-version-mismatch","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}