{"record":{"id":"f3620ff7114c9c0d","repo":"apache/hadoop","slug":"failed-to-stop-active-services","errorCode":null,"errorMessage":"Failed to stop active services","messagePattern":"Failed to stop active services","errorType":"exception","errorClass":"ServiceFailedException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/ActiveState.java","lineNumber":72,"sourceCode":"    }\n    super.setState(context, s);\n  }\n\n  @Override\n  public void enterState(HAContext context) throws ServiceFailedException {\n    try {\n      context.startActiveServices();\n    } catch (IOException e) {\n      throw new ServiceFailedException(\"Failed to start active services\", e);\n    }\n  }\n\n  @Override\n  public void exitState(HAContext context) throws ServiceFailedException {\n    try {\n      context.stopActiveServices();\n    } catch (IOException e) {\n      throw new ServiceFailedException(\"Failed to stop active services\", e);\n    }\n  }\n\n}\n","sourceCodeStart":54,"sourceCodeEnd":77,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/ActiveState.java#L54-L77","documentation":"ActiveState.exitState() delegates to HAContext.stopActiveServices() and wraps any IOException as ServiceFailedException('Failed to stop active services'). It occurs while deactivating an ACTIVE NameNode (transition to standby or shutdown); the underlying cause in the exception identifies which service failed to stop.","triggerScenarios":"'hdfs haadmin -transitionToStandby', failover, or shutdown calls stopActiveServices() and an IOException escapes — e.g., journal manager close failure, checkpointer/upload thread failing to terminate cleanly, storage flush errors on the way down.","commonSituations":"Storage or QJM trouble already present surfaces during teardown; failover under load where threads race shutdown; double transitions triggered by both ZKFC and admin CLI.","solutions":["Read the wrapped cause in the NameNode log to identify the failing subsystem","Verify shared journal (QJM) health and retry the transition after fixing it","If the node is wedged between states, restart the NameNode so HA state is rebuilt cleanly","Avoid issuing concurrent manual transitions and automatic failover to the same node"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  haAdmin.transitionToStandby(nn);\n} catch (ServiceFailedException e) { // \"Failed to stop active services\"\n  Throwable root = e.getCause();\n  LOG.error(\"Standby transition failed, node may be wedged: {}\", root, root);\n  // safest recovery: restart this NameNode so HA state is rebuilt\n}","preventionTips":["Avoid issuing CLI transitions and automatic failover to the same node simultaneously","Keep journal storage healthy — most stop failures are journal/flush errors surfacing at teardown","After any failed transition, verify reported state (hdfs haadmin -getAllServiceState) before further ops"],"tags":["hdfs","namenode","ha","state-transition","shutdown","service-failed"],"backgroundTag":"service-shutdown-failed","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}