{"record":{"id":"d0d195e5e61499fa","repo":"apache/beam","slug":"encountered-a-problem-fetching-table-from-cache","errorCode":null,"errorMessage":"Encountered a problem fetching table {} from cache.","messagePattern":"Encountered a problem fetching table (.+?) from cache\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/TableCache.java","lineNumber":112,"sourceCode":"\n  /** Returns the cached table, using the loader on a miss and refreshing stale entries. */\n  public static Table getAndRefreshIfStale(\n      IcebergCatalogConfig catalogConfig, TableIdentifier identifier, Callable<Table> loader) {\n    CachedTable cachedTable = getEntry(catalogConfig, identifier, loader);\n    cachedTable.refreshIfOlderThan(Instant.now().minus(DEFAULT_REFRESH_INTERVAL));\n    return cachedTable.table;\n  }\n\n  private static CachedTable getEntry(\n      IcebergCatalogConfig catalogConfig, TableIdentifier identifier, Callable<Table> loader) {\n    CacheKey key = new CacheKey(catalogConfig, identifier);\n    try {\n      return TABLES.get(key, () -> new CachedTable(loader.call(), Instant.now()));\n    } catch (ExecutionException | UncheckedExecutionException e) {\n      if (e.getCause() instanceof RuntimeException) {\n        throw (RuntimeException) e.getCause();\n      }\n      throw new RuntimeException(\n          \"Encountered a problem fetching table \" + identifier + \" from cache.\", e);\n    }\n  }\n\n  @VisibleForTesting\n  static long size() {\n    return TABLES.size();\n  }\n\n  @VisibleForTesting\n  static void invalidateAll() {\n    TABLES.invalidateAll();\n  }\n\n  @VisibleForTesting\n  static void put(\n      IcebergCatalogConfig catalogConfig,\n      TableIdentifier identifier,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/TableCache.java#L94-L130","documentation":"TableCache wraps a Guava/Caffeine-style LoadingCache of Iceberg CachedTable entries. When the cache loader throws, the cache library wraps the cause in an ExecutionException or UncheckedExecutionException. If the underlying cause is not a RuntimeException, TableCache re-throws it wrapped in this generic RuntimeException so the original failure (e.g. an Iceberg loader failure while resolving the table) is preserved with context about which table identifier could not be fetched.","triggerScenarios":"Calling TableCache.get(identifier, loader) or cachedTable(...) when the loader.call() that loads the Iceberg table throws a checked/ non-Runtime exception (e.g. Iceberg's table loading fails due to a missing table, bad metadata location, or metastore/warehouse connectivity problem), and the cause is not a RuntimeException.","commonSituations":"Iceberg catalog misconfiguration (wrong warehouse URI, missing metastore connection), table deleted between listing and reading, corrupted metadata.json pointer, or transient object-store auth failures during table load in Beam Iceberg sink/source pipelines.","solutions":["Inspect the wrapped cause (getCause chain) to find the real loader failure and fix it (catalog config, credentials, or table existence).","Verify the table identifier and catalog configuration are correct and the table exists in the target catalog.","Check metastore/warehouse connectivity and credentials (Hive metastore, Glue, Nessie, etc.) before the pipeline runs.","If a checked exception from the loader is expected, wrap the loader logic to throw a RuntimeException with a clearer message instead of relying on the generic wrapper."],"exampleFix":"// before\ncatalog.loadTable(identifier); // throws checked-ish failure, surfaces as generic RuntimeException\n// after\nif (!catalog.tableExists(identifier)) {\n  throw new RuntimeException(\"Table not found in catalog: \" + identifier);\n}\nTable table = catalog.loadTable(identifier);","handlingStrategy":"try-catch","validationCode":"if (!catalog.tableExists(tableIdentifier)) {\n  throw new IllegalArgumentException(\"Table missing from catalog: \" + tableIdentifier);\n}","typeGuard":"if (e.getCause() instanceof RuntimeException rte) { throw rte; } // inspect the real cause first","tryCatchPattern":"try {\n  table = TableCache.get(id, loader);\n} catch (RuntimeException e) {\n  Throwable cause = e.getCause();\n  // route on cause type: missing table, auth failure, metastore outage\n  throw new IllegalStateException(\"Table cache load failed for \" + id, cause);\n}","preventionTips":["Validate catalog connection and credentials before pipeline launch.","Use catalog.tableExists() as a pre-flight check.","Keep Iceberg runtime and connector versions consistent.","Unwrap and log getCause() to diagnose the real loader failure."],"tags":["java","iceberg","cache","beam"],"backgroundTag":"cache-load-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}