{"record":{"id":"af0ca4dd66f0224e","repo":"apache/iceberg","slug":"could-not-find-the-table-during-refresh-setting-c","errorCode":null,"errorMessage":"Could not find the table during refresh, setting current metadata to null","messagePattern":"Could not find the table during refresh, setting current metadata to null","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java","lineNumber":92,"sourceCode":"    return currentMetadata;\n  }\n\n  public String currentMetadataLocation() {\n    return currentMetadataLocation;\n  }\n\n  public int currentVersion() {\n    return version;\n  }\n\n  @Override\n  public TableMetadata refresh() {\n    boolean currentMetadataWasAvailable = currentMetadata != null;\n    try {\n      doRefresh();\n    } catch (NoSuchTableException e) {\n      if (currentMetadataWasAvailable) {\n        LOG.warn(\"Could not find the table during refresh, setting current metadata to null\", e);\n        shouldRefresh = true;\n      }\n\n      currentMetadata = null;\n      currentMetadataLocation = null;\n      version = -1;\n      throw e;\n    }\n    return current();\n  }\n\n  protected void doRefresh() {\n    throw new UnsupportedOperationException(\"Not implemented: doRefresh\");\n  }\n\n  @Override\n  public void commit(TableMetadata base, TableMetadata metadata) {\n    // if the metadata is already out of date, reject it","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/BaseMetastoreTableOperations.java#L74-L110","documentation":"A WARN log emitted during refresh() when the table existed in a previously loaded state but the metastore now reports NoSuchTableException. Iceberg nulls out the cached metadata, metadata location, and version so subsequent operations fail with 'not found' semantics rather than operating on stale state. It indicates the table (or view) was dropped by someone else between your load and this refresh.","triggerScenarios":"Calling Table.refresh() (or any operation triggering doRefresh, like the latestSnapshot accessor with a stale table) after the table was dropped from the catalog by another process; using an expired Table object after DROP TABLE.","commonSituations":"Long-running Spark/Flink streaming queries holding a Table object while another job drops the table; environments with aggressive table lifecycle policies; accidental drops by CI pipelines.","solutions":["Reload the table from the catalog; if loadTable throws NoSuchTableException, recreate the table or stop the consuming job.","Verify whether the drop was intentional (audit catalog change logs).","For streaming jobs, add logic to detect table deletion and fail fast or recreate with the original schema.","Re-enable your table from backups if the drop was accidental."],"exampleFix":"// before\nTable table = catalog.loadTable(\"db.tbl\"); /* long-lived */ ... table.refresh();\n// after\nTable table;\ntry { table = catalog.loadTable(\"db.tbl\"); } catch (NoSuchTableException e) { table = recreateTable(); }","handlingStrategy":"try-catch","validationCode":"// check existence before refresh\nif (!catalog.tableExists(identifier)) { /* recreate or stop */ }","typeGuard":null,"tryCatchPattern":"try { table.refresh(); } catch (NoSuchTableException e) { table = catalog.loadTable(id); /* or recreate */ }","preventionTips":["Don't hold Table references across long periods; reload from catalog instead","Check tableExists before operating on cached tables","Audit who/what can DROP TABLE in your environment","For streaming jobs, handle table deletion explicitly"],"tags":["refresh","table-not-found","stale-metadata"],"backgroundTag":"entity-not-found","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"}