apache/hadoop · error · IOException

Cannot finalize with no NameNode active

Error message

Cannot finalize with no NameNode active

What it means

Implements `hdfs dfsadmin -finalizeUpgrade` when the filesystem URI is an HA logical URI (hdfs://<nameservice>). DFSAdmin resolves every NameNode of the nameservice, checks HAUtil.isAtLeastOneActive, and fails fast with IOException('Cannot finalize with no NameNode active') before issuing any finalize RPC — meaning both NameNodes are in STANDBY at that moment.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java:1500

  /**
   * Command to ask the namenode to finalize previously performed upgrade.
   * Usage: hdfs dfsadmin -finalizeUpgrade
   * @exception IOException 
   */
  public int finalizeUpgrade() throws IOException {
    DistributedFileSystem dfs = getDFS();
    
    Configuration dfsConf = dfs.getConf();
    URI dfsUri = dfs.getUri();
    boolean isHaAndLogicalUri = HAUtilClient.isLogicalUri(dfsConf, dfsUri);
    if (isHaAndLogicalUri) {
      // In the case of HA and logical URI, run finalizeUpgrade for all
      // NNs in this nameservice.
      String nsId = dfsUri.getHost();
      List<ClientProtocol> namenodes =
          HAUtil.getProxiesForAllNameNodesInNameservice(dfsConf, nsId);
      if (!HAUtil.isAtLeastOneActive(namenodes)) {
        throw new IOException("Cannot finalize with no NameNode active");
      }

      List<ProxyAndInfo<ClientProtocol>> proxies =
          HAUtil.getProxiesForAllNameNodesInNameservice(dfsConf,
          nsId, ClientProtocol.class);
      List<IOException> exceptions = new ArrayList<>();
      for (ProxyAndInfo<ClientProtocol> proxy : proxies) {
        try{
          proxy.getProxy().finalizeUpgrade();
          System.out.println("Finalize upgrade successful for " +
              proxy.getAddress());
        }catch (IOException ioe){
          System.err.println("Finalize upgrade failed for " +
              proxy.getAddress());
          exceptions.add(ioe);
        }
      }
      if(!exceptions.isEmpty()){

View on GitHub (pinned to 2add963021)

Solutions

  1. Check states: hdfs haadmin -ns <ns> -getAllServiceState
  2. Make one NameNode active: hdfs haadmin -transitionToActive <nnId>, or fix ZKFC/ZooKeeper so automatic failover elects one
  3. Retry hdfs dfsadmin -finalizeUpgrade once an active exists
  4. If dual-standby was planned (e.g. full-cluster stop for upgrade), run finalize from the active after it starts, or use the non-HA URI of a single NN

Example fix

# before
$ hdfs dfsadmin -finalizeUpgrade
# IOException: Cannot finalize with no NameNode active

# after
$ hdfs haadmin -ns mycluster -getAllServiceState
$ hdfs haadmin -transitionToActive nn1
$ hdfs dfsadmin -finalizeUpgrade
Defensive patterns

Strategy: validation

Validate before calling

# pre-flight: require at least one active NN in the nameservice
hdfs haadmin -ns "$NS" -getAllServiceState | grep -q ': active' || {
  echo "no active NameNode in $NS; refusing to finalize" >&2; exit 2;
}
hdfs dfsadmin -finalizeUpgrade

Prevention

When it happens

Trigger: Active NameNode crashed without failover (ZKFC down, ZooKeeper quorum loss); both NNs deliberately put in standby for maintenance and finalizeUpgrade run anyway; script running right after stopping the active for a restart; failover disabled in a manual-HA setup.

Common situations: Post failover-drill cleanup; ZooKeeper outage leaving no elected active; maintenance windows where operators forget finalize needs a writer NN; fresh HA clusters before first election.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/af38796a9cd7093c. Report an issue: GitHub.