apache/hadoop · error · RuntimeException

Not able to initialize fs in getDefaultReplication for path

Error message

Not able to initialize fs in  getDefaultReplication for path <f> with exception

What it means

In ViewFileSystem.getDefaultReplication(Path), resolving the path requires initializing the target FileSystem of its mount point. An IOException raised during that initialization (name node unreachable, bad HA config, security failure) is wrapped in an unchecked RuntimeException whose message names the operation and path; the real IOException is the cause.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java:989

      return res.targetFileSystem.getDefaultBlockSize(res.remainingPath);
    } catch (FileNotFoundException e) {
      throw new NotInMountpointException(f, "getDefaultBlockSize");
    } catch (IOException e) {
      throw new RuntimeException("Not able to initialize fs in "
          + " getDefaultBlockSize for path " + f + " with exception", e);
    }
  }

  @Override
  public short getDefaultReplication(Path f) {
    try {
      InodeTree.ResolveResult<FileSystem> res =
        fsState.resolve(getUriPath(f), true);
      return res.targetFileSystem.getDefaultReplication(res.remainingPath);
    } catch (FileNotFoundException e) {
      throw new NotInMountpointException(f, "getDefaultReplication");
    } catch (IOException e) {
      throw new RuntimeException("Not able to initialize fs in "
          + " getDefaultReplication for path " + f + " with exception", e);
    }
  }

  @Override
  public FsServerDefaults getServerDefaults(Path f) throws IOException {
    try {
      InodeTree.ResolveResult<FileSystem> res =
          fsState.resolve(getUriPath(f), true);
      return res.targetFileSystem.getServerDefaults(res.remainingPath);
    } catch (FileNotFoundException e) {
      throw new NotInMountpointException(f, "getServerDefaults");
    }
  }

  @Override
  public ContentSummary getContentSummary(Path f) throws IOException {
    InodeTree.ResolveResult<FileSystem> res =

View on GitHub (pinned to 2add963021)

Solutions

  1. Unwrap and inspect the cause IOException to identify the failing authority
  2. Probe each mount target directly: `hadoop fs -ls hdfs://<authority-from-mount-table>/`
  3. Correct the mount entry or provide the missing HA/failover configuration on the client
  4. Guard generic code: catch RuntimeException, check for IOException cause, and degrade gracefully (report target cluster outage)

Example fix

// before
short rep = fs.getDefaultReplication(outDir); // RuntimeException with buried cause

// after
short rep;
try {
  rep = fs.getDefaultReplication(outDir);
} catch (RuntimeException e) {
  if (e.getCause() instanceof IOException) {
    throw new IOException("Target FS of " + outDir + " down: " + e.getCause().getMessage(), e.getCause());
  }
  throw e;
}
Defensive patterns

Strategy: retry

Validate before calling

// Pre-flight: initialize each target FileSystem in the mount table once
static void preflightMounts(Configuration conf) throws IOException {
  for (Map.Entry<String,String> e : conf) {
    if (e.getKey().startsWith("fs.viewfs.mounttable.")) {
      FileSystem.get(new URI(e.getValue()), conf).exists(new Path("/"));
    }
  }
}

Try / catch

try {
  short rep = fs.getDefaultReplication(p);
} catch (RuntimeException e) {
  Throwable c = e.getCause();
  if (c instanceof IOException) {
    // target FS down: retry with backoff or fail over per HA config
    throw new IOException("viewfs target for " + p + " unreachable", c);
  }
  throw e;
}

Prevention

When it happens

Trigger: getDefaultReplication(path) on a path whose mount entry targets an HDFS that is down, a nameservice not defined in the client's hdfs-site.xml, a wrong port/authority in fs.viewfs.mounttable.default.link.*, or a Kerberos/TLS failure while creating the proxy FileSystem.

Common situations: Federated clusters where one sub-cluster is unavailable; clients that copied core-site.xml (mount table) but not the matching hdfs-site.xml; DR failovers where the mount table still references the dead cluster.

Related errors


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