{"record":{"id":"3db7db943ae3508f","repo":"apache/hadoop","slug":"failed-to-become-active","errorCode":null,"errorMessage":"Failed to become active. {}","messagePattern":"Failed to become active\\. (.+?)","errorType":"exception","errorClass":"ServiceFailedException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java","lineNumber":740,"sourceCode":"      \n      throw new ServiceFailedException(\"Unable to become active. \" +\n          \"Local node did not get an opportunity to do so from ZooKeeper, \" +\n          \"or the local node took too long to transition to active.\");\n    }\n\n    // Phase 5. At this point, we made some attempt to become active. So we\n    // can tell the old active to rejoin if it wants. This allows a quick\n    // fail-back if we immediately crash.\n    for (ZKFCProtocol zkfc : otherZkfcs) {\n      zkfc.cedeActive(-1);\n    }\n\n    if (attempt.succeeded) {\n      LOG.info(\"Successfully became active. \" + attempt.status);\n    } else {\n      // Propagate failure\n      String msg = \"Failed to become active. \" + attempt.status;\n      throw new ServiceFailedException(msg);\n    }\n  }\n\n  /**\n   * Ask the remote zkfc to cede its active status and wait for the specified\n   * timeout before attempting to claim leader status.\n   * @param remote node to ask\n   * @param timeout amount of time to cede\n   * @return the {@link ZKFCProtocol} used to talk to the ndoe\n   * @throws IOException\n   */\n  private ZKFCProtocol cedeRemoteActive(HAServiceTarget remote, int timeout)\n    throws IOException {\n    LOG.info(\"Asking \" + remote + \" to cede its active state for \"\n               + timeout + \"ms\");\n    ZKFCProtocol oldZkfc = remote.getZKFCProxy(conf, timeout);\n    oldZkfc.cedeActive(timeout);\n    return oldZkfc;","sourceCodeStart":722,"sourceCodeEnd":758,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ha/ZKFailoverController.java#L722-L758","documentation":"gracefulFailover() Phase 5: an ActiveAttemptRecord exists but succeeded=false, so the recorded failure status is propagated as ServiceFailedException('Failed to become active. <status>'). The local node did attempt transitionToActive and the attempt failed; attempt.status (captured by recordActiveAttempt) carries the underlying reason.","triggerScenarios":"becomeActive() on the local node failed: the local NameNode rejected transitionToActive (e.g. cannot write to the JournalNode quorum, storage/upgrade state refuses active), recorded as a failed ActiveAttemptRecord and surfaced after the old active was told to rejoin.","commonSituations":"JournalNodes unavailable or in a torn state; NN in the middle of an upgrade/rollback; shared edits dir errors; the same root causes as 'Couldn't transition to active' but reached via the graceful-failover path.","solutions":["Read attempt.status in the exception message together with the local NameNode log — it contains the transition failure reason.","Fix the transition blocker (typically QJM/JournalNode availability or local storage).","Retry graceful failover after repair; the old active has already been told to rejoin (cedeActive(-1)) so both nodes are back in the election."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Before failover: confirm the target can become active in principle —\n// JournalNodes reachable, storage writable (same pre-flight as 1033).\n// hdfs haadmin -checkHealth <nnId> plus JN port probes from the target host.","typeGuard":null,"tryCatchPattern":"try {\n  zkfc.gracefulFailover();\n} catch (ServiceFailedException e) {\n  if (e.getMessage().startsWith(\"Failed to become active.\")) {\n    String status = e.getMessage().substring(\"Failed to become active.\".length());\n    // status is the recorded ActiveAttemptRecord — the NN's own failure text;\n    // fix that (usually QJM), then retry; old active already rejoined election\n  }\n}","preventionTips":["Treat any failed transitionToActive in NN logs as a blocker to clear before the next failover window.","Keep JournalNode health monitored; it is the dominant root cause surfaced by this error.","Dry-run failovers in staging after upgrades to catch transition regressions before production."],"tags":["hadoop","high-availability","graceful-failover","state-transition"],"backgroundTag":"state-transition-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}