{"record":{"id":"26098cfb7d442d1f","repo":"apache/hadoop","slug":"not-able-to-initialize-fs-in-getdefaultblocksize","errorCode":null,"errorMessage":"Not able to initialize fs in  getDefaultBlockSize for path <f> with exception","messagePattern":"Not able to initialize fs in  getDefaultBlockSize for path <f> with exception","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java","lineNumber":975,"sourceCode":"  public short getDefaultReplication() {\n    throw new NotInMountpointException(\"getDefaultReplication\");\n  }\n\n  @Override\n  public FsServerDefaults getServerDefaults() throws IOException {\n    throw new NotInMountpointException(\"getServerDefaults\");\n  }\n\n  @Override\n  public long getDefaultBlockSize(Path f) {\n    try {\n      InodeTree.ResolveResult<FileSystem> res =\n        fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getDefaultBlockSize(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getDefaultBlockSize\");\n    } catch (IOException e) {\n      throw new RuntimeException(\"Not able to initialize fs in \"\n          + \" getDefaultBlockSize for path \" + f + \" with exception\", e);\n    }\n  }\n\n  @Override\n  public short getDefaultReplication(Path f) {\n    try {\n      InodeTree.ResolveResult<FileSystem> res =\n        fsState.resolve(getUriPath(f), true);\n      return res.targetFileSystem.getDefaultReplication(res.remainingPath);\n    } catch (FileNotFoundException e) {\n      throw new NotInMountpointException(f, \"getDefaultReplication\");\n    } catch (IOException e) {\n      throw new RuntimeException(\"Not able to initialize fs in \"\n          + \" getDefaultReplication for path \" + f + \" with exception\", e);\n    }\n  }\n","sourceCodeStart":957,"sourceCodeEnd":993,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java#L957-L993","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncatch (RuntimeException e) {\n  throw e; // opaque 'Not able to initialize fs...' crash\n}\n\n// after\ncatch (RuntimeException e) {\n  Throwable c = e.getCause();\n  if (c instanceof IOException) {\n    throw new IOException(\"ViewFs target for \" + path + \" unavailable: \" + c.getMessage(), c);\n  }\n  throw e;\n}","handlingStrategy":"retry","validationCode":"// Probe the target authority of the mount before depending on it\nstatic boolean targetReachable(Configuration conf, String authority) {\n  try {\n    FileSystem t = FileSystem.get(new URI(\"hdfs://\" + authority), conf);\n    t.exists(new Path(\"/\"));\n    return true;\n  } catch (IOException e) {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  long bs = fs.getDefaultBlockSize(p);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof IOException) {\n    // transient target-FS outage: unwrap, log, retry after backoff\n    LOG.warn(\"viewfs target for \" + p + \" unavailable\", e.getCause());\n  } else { throw e; }\n}","preventionTips":["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"],"tags":["viewfs","hadoop","hdfs","ha","connection","runtimeexception"],"backgroundTag":"target-filesystem-unreachable","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}