{"record":{"id":"2fd65ff32e947f33","repo":"prestodb/presto","slug":"failed-to-retrieve-table-metadata-from-newlocati","errorCode":null,"errorMessage":"failed to retrieve table metadata from ${newLocation}","messagePattern":"failed to retrieve table metadata from (.+?)","errorType":"exception","errorClass":"TableNotFoundException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java","lineNumber":455,"sourceCode":"        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\n    private boolean shouldRetry(Exception exception)\n    {\n        return !(exception.getCause() instanceof FileNotFoundException);\n    }","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/HiveTableOperations.java#L437-L473","documentation":"After successfully parsing the metadata file, refreshFromMetadataLocation() verifies newMetadata was set; if it is still null (the retry runnable completed without producing metadata) it throws TableNotFoundException 'failed to retrieve table metadata from <newLocation>'. This is the edge case where reading neither threw nor produced content.","triggerScenarios":"refresh() where the retry loop returns normally but newMetadata remains unset — practically a corrupted/empty cached input stream or a read that silently returned nothing from the metadata location.","commonSituations":"Truncated or zero-byte metadata JSON on object storage; caching layer returning empty content; partially failed write that left an invalid metadata file in place.","solutions":["Inspect the metadata file at the reported location (size/integrity) and repair or restore it from the previous valid metadata version.","Roll the HMS METADATA_LOCATION back to the last known-good metadata JSON if the current one is corrupt.","Clear any file-I/O cache (fileIO.newCachedInputFile) that may have cached the empty response.","Run Iceberg metadata validation/repair tooling (e.g. remove_orphan_files carefully, restore from backups)."],"exampleFix":"// before (assume latest is good)\nString location = table.parameters().get(METADATA_LOCATION);\n// after — verify content before use, else fall back to previous version\nbyte[] bytes = readAll(location);\nif (bytes.length == 0) {\n    location = previousMetadataLocation; // from PREVIOUS_METADATA_LOCATION param\n}","handlingStrategy":"fallback","validationCode":"// verify metadata file size and parseability before trusting it\nbyte[] b = readAllBytes(metadataLocation); if (b.length == 0) fail(\"empty metadata file\");","typeGuard":null,"tryCatchPattern":"try { table.refresh(); }\ncatch (TableNotFoundException e) { /* fall back to PREVIOUS_METADATA_LOCATION or restore from backup */ }","preventionTips":["Back up metadata JSON files before manual repairs.","Monitor object storage for truncated/zero-byte writes.","Avoid hand-editing METADATA_LOCATION."],"tags":["iceberg","metadata","corruption","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"}