{"record":{"id":"faa6543fc797cc0d","repo":"apache/hadoop","slug":"couldn-t-transition-to-active","errorCode":null,"errorMessage":"Couldn't transition to active","messagePattern":"Couldn't transition to active","errorType":"exception","errorClass":"ServiceFailedException","httpStatus":null,"severity":"critical","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java","lineNumber":433,"sourceCode":"          conf, FailoverController.getRpcTimeoutToNewActive(conf)),\n          createReqInfo());\n      String msg = \"Successfully transitioned \" + localTarget +\n          \" to active state\";\n      LOG.info(msg);\n      serviceState = HAServiceState.ACTIVE;\n      recordActiveAttempt(new ActiveAttemptRecord(true, msg));\n\n    } catch (Throwable t) {\n      String msg = \"Couldn't make \" + localTarget + \" active\";\n      LOG.error(msg, t);\n      \n      recordActiveAttempt(new ActiveAttemptRecord(false, msg + \"\\n\" +\n          StringUtils.stringifyException(t)));\n\n      if (t instanceof ServiceFailedException) {\n        throw (ServiceFailedException)t;\n      } else {\n        throw new ServiceFailedException(\"Couldn't transition to active\",\n            t);\n      }\n/*\n* TODO:\n* we need to make sure that if we get fenced and then quickly restarted,\n* none of these calls will retry across the restart boundary\n* perhaps the solution is that, whenever the nn starts, it gets a unique\n* ID, and when we start becoming active, we record it, and then any future\n* calls use the same ID\n*/\n      \n    }\n  }\n\n  /**\n   * Store the results of the last attempt to become active.\n   * This is used so that, during manually initiated failover,\n   * we can report back the results of the attempt to become active","sourceCodeStart":415,"sourceCodeEnd":451,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java#L415-L451","documentation":"ZKFailoverController.becomeActive() wraps any non-ServiceFailedException Throwable thrown while making the local service active into ServiceFailedException(\"Couldn't transition to active\", t). The local service (typically a NameNode) refused or failed the transitionToActive call and the ZKFC reports the failure after recording a failed ActiveAttemptRecord.","triggerScenarios":"The local service's transitionToActive throws an IOException or RuntimeException rather than ServiceFailedException — e.g. JournalNode quorum unavailable so the NN cannot start writing edits, NN not ready / still starting, storage or shared-edits misconfiguration on the local node.","commonSituations":"JournalNodes down when this ZKFC wins the election; dfs.namenode.shared.edits.dir wrong on the local node; NN transitioning slowly (large image/edits) and internal calls time out; disk full on the edits dir.","solutions":["Read the wrapped cause: the preceding log 'Couldn't make <target> active' plus the NameNode's own log states the real reason.","Ensure all JournalNodes are up and the local NameNode can write to the shared edits (check JN process, ports, dfs.journalnode.* addresses).","If the NN is not ready yet, let the ZKFC retry — election will be re-attempted; fix the NN-reported blocker first.","Verify local storage dirs are writable and not full."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before relying on election: verify the local NN can write shared edits\n// e.g. ensure JournalNodes are up from the NN host:\n//   for jn in jn1 jn2 jn3: nc -z $jn 8485\n// And check local storage dirs writable. There is no public API that\n// 'pre-flights' transitionToActive without side effects.","typeGuard":null,"tryCatchPattern":"try {\n  zkfcInitiatedElection(); // or rely on ZKFC retry loop\n} catch (ServiceFailedException sfe) {\n  if (\"Couldn't transition to active\".equals(sfe.getMessage())) {\n    Throwable root = sfe.getCause(); // the NN's real failure\n    // fix JournalNodes/storage per root cause; ZKFC retries election\n  }\n}","preventionTips":["Keep JournalNodes monitored (odd set, majority up) — most transitionToActive failures are QJM write failures.","Keep the standby's checkpoint state current so transitions are fast and edits replay is short.","Watch ZKFC logs for 'Couldn't make ... active' and treat repeated occurrences as an election-storm symptom."],"tags":["hadoop","high-availability","zkfc","name-node","state-transition"],"backgroundTag":"state-transition-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}