{"record":{"id":"c8b7c2f3763c1284","repo":"apache/iceberg","slug":"failed-to-get-block-locations-for-path-s","errorCode":null,"errorMessage":"Failed to get block locations for path: %s","messagePattern":"Failed to get block locations for path: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java","lineNumber":226,"sourceCode":"  public FileStatus getStat() {\n    return lazyStat();\n  }\n\n  public Path getPath() {\n    return path;\n  }\n\n  public String[] getBlockLocations(long start, long end) {\n    List<String> hosts = Lists.newArrayList();\n    try {\n      for (BlockLocation bl : fs.getFileBlockLocations(path, start, end)) {\n        Collections.addAll(hosts, bl.getHosts());\n      }\n\n      return hosts.toArray(NO_LOCATION_PREFERENCE);\n\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Failed to get block locations for path: %s\", path);\n    }\n  }\n\n  @Override\n  public String location() {\n    return location;\n  }\n\n  @Override\n  public boolean exists() {\n    try {\n      return lazyStat() != null;\n    } catch (NotFoundException e) {\n      return false;\n    }\n  }\n\n  @Override","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopInputFile.java#L208-L244","documentation":"HadoopInputFile.getBlockLocations wraps Hadoop's FileSystem.getFileBlockLocations IOException in a RuntimeIOException. This is used for locality-aware planning; failure means the filesystem metadata call failed.","triggerScenarios":"Calling getBlockLocations (directly or via Iceberg's locality/planning code) when the underlying FileSystem call throws IOException — NameNode unavailable, RPC timeout, path concurrently deleted.","commonSituations":"Busy/unreachable NameNode or HDFS in safe mode; S3-backed paths where block-location metadata is unavailable or calls fail intermittently; permissions issues fetching block info.","solutions":["Retry the call — HDFS metadata RPCs fail transiently under load (use Tasks.foreach with retry like the rest of Iceberg)","Check NameNode health / cluster connectivity","Verify the file still exists before requesting block locations","Disable or bypass locality optimization if block locations are not needed"],"exampleFix":"// before\nString[] hosts = inputFile.getBlockLocations(0, len);\n// after\nString[] hosts = Tasks.foreach(inputFile)\n    .retry(3).exponentialBackoff(100, 1000, 10000)\n    .throwFailureWhenFinished()\n    .run(file -> file.getBlockLocations(0, len));","handlingStrategy":"retry","validationCode":"if (!inputFile.exists()) {\n  throw new NotFoundException(\"Cannot get block locations, missing: %s\", inputFile.location());\n}","typeGuard":null,"tryCatchPattern":"try { return file.getBlockLocations(start, len); }\ncatch (RuntimeIOException e) {\n  LOG.warn(\"Block location lookup failed, skipping locality optimization\", e);\n  return new String[0]; // proceed without locality\n}","preventionTips":["Wrap metadata calls in Tasks.foreach retry with backoff","Monitor NameNode health and RPC latency","Fall back to no-locality planning instead of failing the whole job"],"tags":["hadoop","io","hdfs"],"backgroundTag":"file-read-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}