{"record":{"id":"e797a2b6d244543d","repo":"apache/hadoop","slug":"cannot-transition-from-observer-to-active","errorCode":null,"errorMessage":"Cannot transition from 'observer' to 'active'","messagePattern":"Cannot transition from 'observer' to 'active'","errorType":"exception","errorClass":"ServiceFailedException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java","lineNumber":2018,"sourceCode":"    }\n    if (!getNamesystem().nameNodeHasResourcesAvailable()) {\n      throw new HealthCheckFailedException(\n          \"The NameNode has no resources available\");\n    }\n    if (notBecomeActiveInSafemode && isInSafeMode()) {\n      throw new HealthCheckFailedException(\"The NameNode is configured to \" +\n          \"report UNHEALTHY to ZKFC in Safemode.\");\n    }\n  }\n  \n  synchronized void transitionToActive() throws IOException {\n    String operationName = \"transitionToActive\";\n    namesystem.checkSuperuserPrivilege(operationName);\n    if (!haEnabled) {\n      throw new ServiceFailedException(\"HA for namenode is not enabled\");\n    }\n    if (state == OBSERVER_STATE) {\n      throw new ServiceFailedException(\n          \"Cannot transition from '\" + OBSERVER_STATE + \"' to '\" +\n              ACTIVE_STATE + \"'\");\n    }\n    if (notBecomeActiveInSafemode && isInSafeMode()) {\n      throw new ServiceFailedException(getRole() + \" still not leave safemode\");\n    }\n    state.setState(haContext, ACTIVE_STATE);\n  }\n\n  synchronized void transitionToStandby() throws IOException {\n    String operationName = \"transitionToStandby\";\n    namesystem.checkSuperuserPrivilege(operationName);\n    if (!haEnabled) {\n      throw new ServiceFailedException(\"HA for namenode is not enabled\");\n    }\n    state.setState(haContext, STANDBY_STATE);\n  }\n","sourceCodeStart":2000,"sourceCodeEnd":2036,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java#L2000-L2036","documentation":"transitionToActive explicitly rejects promotion from OBSERVER_STATE: the HA state machine only allows standby (or initializing) NameNodes to become active, because an Observer serves reads against a tailing namespace and lacks the edit-log ownership an active NN must assume. The transition must go through standby.","triggerScenarios":"'hdfs haadmin -transitionToActive <nnId>' (or HAServiceProtocol.transitionToActive) while the target NameNode's state is OBSERVER - e.g., after deploying Observer NameNodes (read-only scalable reads, Router-based federation setups).","commonSituations":"Operators treating observer like standby during manual failover drills; automation scripts that pick 'any non-active NN' and pick the observer; misunderstanding of the observer state model introduced for read scaling.","solutions":["Transition observer -> standby first, then standby -> active: 'hdfs haadmin -transitionToStandby <nnId>' followed by '-transitionToActive <nnId>'.","Prefer promoting a genuine standby NN (one tailing edits) rather than the observer.","In ZKFC-managed deployments, let automatic failover handle promotion from standby instead of manual transitions."],"exampleFix":"# before\nhdfs haadmin -transitionToActive nn1   # nn1 is an Observer -> rejected\n\n# after\nhdfs haadmin -transitionToStandby nn1\nhdfs haadmin -transitionToActive nn1   # observer -> standby -> active","handlingStrategy":"validation","validationCode":"// refuse to promote an observer directly\nHAServiceStatus st = haProxy.getServiceStatus(nnId);\nif (\"OBSERVER\".equals(String.valueOf(st.getState())))\n  throw new IllegalStateException(\"transition observer to standby first\");\nhaProxy.transitionToActive(nnId);","typeGuard":"boolean isObserverToActiveDenied(Throwable t) {\n  return t instanceof ServiceFailedException\n      && String.valueOf(t.getMessage()).contains(\"'observer' to 'active'\");\n}","tryCatchPattern":null,"preventionTips":["Check 'hdfs haadmin -getServiceStatus' before every manual transition; encode observer->standby->active in tooling.","Prefer promoting standby NNs; treat observers as read nodes only.","Teach failover automation to exclude observer-state NNs from the candidate set."],"tags":["hdfs","namenode","ha","observer","state-transition","failover"],"backgroundTag":"ha-state-transition-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}