apache/hadoop · error · RuntimeException
Not able to initialize fs in getDefaultBlockSize for path <
Error message
Not able to initialize fs in getDefaultBlockSize for path <f> with exception
What it means
In ViewFileSystem.getDefaultBlockSize(Path), fsState.resolve() must initialize the target FileSystem of the mount point (connect to the name node). If that step throws an IOException, the code wraps it in an unchecked RuntimeException ('Not able to initialize fs in getDefaultBlockSize for path ... with exception'). The original IOException is attached as the cause and holds the real reason, such as an unreachable name service or a bad HA configuration.
Source
Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java:975
public short getDefaultReplication() {
throw new NotInMountpointException("getDefaultReplication");
}
@Override
public FsServerDefaults getServerDefaults() throws IOException {
throw new NotInMountpointException("getServerDefaults");
}
@Override
public long getDefaultBlockSize(Path f) {
try {
InodeTree.ResolveResult<FileSystem> res =
fsState.resolve(getUriPath(f), true);
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);
}
}
View on GitHub (pinned to 2add963021)
Solutions
- Read the cause: ((IOException) e.getCause()).getMessage() tells whether it is connection refused, unknown host, or config lookup failure
- Verify each mount target is reachable directly: `hadoop fs -ls hdfs://nameservice1/` using the exact authority from the mount table
- Fix the mount table entry or ship the missing HA config (hdfs-site.xml with dfs.ha.namenodes.<id>, dfs.client.failover.proxyProvider.<id>) to the client
- In generic tools, catch RuntimeException, unwrap the IOException cause, and report a target-cluster outage instead of crashing
Example fix
// before
catch (RuntimeException e) {
throw e; // opaque 'Not able to initialize fs...' crash
}
// after
catch (RuntimeException e) {
Throwable c = e.getCause();
if (c instanceof IOException) {
throw new IOException("ViewFs target for " + path + " unavailable: " + c.getMessage(), c);
}
throw e;
} Defensive patterns
Strategy: retry
Validate before calling
// Probe the target authority of the mount before depending on it
static boolean targetReachable(Configuration conf, String authority) {
try {
FileSystem t = FileSystem.get(new URI("hdfs://" + authority), conf);
t.exists(new Path("/"));
return true;
} catch (IOException e) {
return false;
}
} Try / catch
try {
long bs = fs.getDefaultBlockSize(p);
} catch (RuntimeException e) {
if (e.getCause() instanceof IOException) {
// transient target-FS outage: unwrap, log, retry after backoff
LOG.warn("viewfs target for " + p + " unavailable", e.getCause());
} else { throw e; }
} Prevention
- Health-check every authority referenced by fs.viewfs.mounttable.* before job submission
- Ship matching core-site.xml and hdfs-site.xml (HA settings) to every client using the viewfs URI
- Treat 'Not able to initialize fs' RuntimeExceptions as target-cluster outages: alert on the IOException cause, not the wrapper
When it happens
Trigger: A mount table entry points at an unreachable authority (hdfs://nameservice1 with the NN down or wrong port), an HA nameservice missing from the client config, a failover cluster where only a standby is reachable, or a wrong scheme/authority typo in fs.viewfs.mounttable.default.link.*; getDefaultBlockSize(Path) is then called on a path under that mount.
Common situations: Merged clusters after federation where one sub-cluster is down; client machines missing hdfs-site.xml HA definitions (dfs.ha.namenodes.*); mount table copied from production into a test environment whose name services do not exist; DNS/Kerberos failures during target FS initialization.
Related errors
- Not able to initialize fs in getDefaultReplication for path
- {} does not support method msync
- {} is in observer state. Cannot be failover target
- Unexpected HAServiceStateProto:
- Unexpected HAServiceState:
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/26098cfb7d442d1f.
Report an issue: GitHub.