{"record":{"id":"19221f348ccf0904","repo":"prestodb/presto","slug":"table-metadata-is-missing","errorCode":null,"errorMessage":"Table metadata is missing","messagePattern":"Table metadata is missing","errorType":"exception","errorClass":"TableNotFoundException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java","lineNumber":451,"sourceCode":"            shouldRefresh = false;\n            return;\n        }\n\n        AtomicReference<TableMetadata> newMetadata = new AtomicReference<>();\n        try {\n            Tasks.foreach(newLocation)\n                    .retry(config.getTableRefreshRetries())\n                    .shouldRetryTest(this::shouldRetry)\n                    .exponentialBackoff(\n                            config.getTableRefreshBackoffMinSleepTime().toMillis(),\n                            config.getTableRefreshBackoffMaxSleepTime().toMillis(),\n                            config.getTableRefreshMaxRetryTime().toMillis(),\n                            config.getTableRefreshBackoffScaleFactor())\n                    .run(metadataLocation -> newMetadata.set(\n                            TableMetadataParser.read(fileIO, fileIO.newCachedInputFile(metadataLocation))));\n        }\n        catch (RuntimeException e) {\n            throw new TableNotFoundException(getSchemaTableName(), \"Table metadata is missing\", e);\n        }\n\n        if (newMetadata.get() == null) {\n            throw new TableNotFoundException(getSchemaTableName(), \"failed to retrieve table metadata from \" + newLocation);\n        }\n\n        String newUUID = newMetadata.get().uuid();\n        if (currentMetadata != null) {\n            checkState(newUUID == null || newUUID.equals(currentMetadata.uuid()),\n                    \"Table UUID does not match: current=%s != refreshed=%s\", currentMetadata.uuid(), newUUID);\n        }\n\n        currentMetadata = newMetadata.get();\n        currentMetadataLocation = newLocation;\n        version = parseVersion(newLocation);\n        shouldRefresh = false;\n    }\n","sourceCodeStart":433,"sourceCodeEnd":469,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java#L433-L469","documentation":"refreshFromMetadataLocation() retries reading and parsing the Iceberg TableMetadata JSON from the metadata location; if any RuntimeException occurs during the retry window it throws TableNotFoundException 'Table metadata is missing'. This usually means the metadata file referenced by the HMS table can no longer be read.","triggerScenarios":"table.refresh() (invoked by reads, DDL, or system tables) when fileIO.newCachedInputFile(metadataLocation) fails — file deleted by expiry/cleanup, credentials/permission issue, or transient storage outage that outlasts the retry budget (table-refresh max retry time/backoff).","commonSituations":"Metadata file removed by expire_snapshots/cleanup jobs or a table 'rollback' while a query is running; S3/GCS credentials expiring; misconfigured FS paths (wrong warehouse location) after catalog migration.","solutions":["Re-read the table: the HMS entry now points at a new metadata file; retry the query/operation.","Check whether a retention/expiry job deleted the metadata file; restore it or lower aggressive cleanup settings.","Verify storage permissions/credentials for the Presto service account on the metadata location.","Increase iceberg.table-refresh-max-retry-time / backoff if the outage is transient but longer than the retry window."],"exampleFix":"// before (aggressive cleanup while readers are active)\ntable.expireSnapshots().expireOlderThan(System.currentTimeMillis()).commit();\n// after — retain recent metadata readers may reference\ntable.expireSnapshots()\n     .expireOlderThan(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(7))\n     .commit();","handlingStrategy":"retry","validationCode":"// pre-check readability of the metadata location\nboolean readable = fileIO.newInputFile(metadataLocation).exists();","typeGuard":null,"tryCatchPattern":"try { table.refresh(); }\ncatch (TableNotFoundException e) { /* re-resolve table from catalog; check cleanup jobs/permissions */ }","preventionTips":["Don't expire snapshots/metadata more aggressively than readers' lifetimes.","Ensure Presto's storage credentials don't expire mid-query.","Raise table-refresh retry time/backoff for flaky storage."],"tags":["iceberg","metadata","file-not-found","storage"],"backgroundTag":"metadata-file-missing","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}