apache/iceberg · warning

Failed to load table metadata for table

Error message

Failed to load table metadata for table: {}, continuing drop without purge

What it means

A warning from DynamoDbCatalog.dropTable: when purge=true the catalog tries to load the table's current metadata to delete the underlying data files, but TableOperations.current() threw NotFoundException. The catalog proceeds to delete the table's DynamoDB entry anyway, skipping the data-file purge, so orphan data files may remain in storage.

Solutions

  1. If the warning appears but you need a clean purge, restore/verify the metadata JSON is readable before dropping, or run an orphan-file cleanup (RemoveOrphanFiles) afterwards
  2. Verify the FileIO configuration (credentials, region, endpoint) can read the metadata location
  3. If you don't care about the data files, call dropTable with purge=false to make the intent explicit
  4. Check that the DynamoDB record's metadata_location field points to an existing object

Example fix

// before
catalog.dropTable(TableIdentifier.of("db", "tbl"), true); // warns, data files orphaned
// after
Table table = catalog.loadTable(TableIdentifier.of("db", "tbl")); // fails fast if metadata unreadable
table.io() /* verify metadata accessible */;
catalog.dropTable(TableIdentifier.of("db", "tbl"), true);
// then schedule RemoveOrphanFiles for leftovers
Defensive patterns

Strategy: fallback

Validate before calling

// verify metadata is loadable before purging
TableMetadata meta;
try { meta = catalog.loadTable(identifier).operations().current(); }
catch (NotFoundException e) { /* purge will be skipped */ }

Prevention

When it happens

Trigger: Calling DynamoDbCatalog.dropTable(identifier, purge=true) when the DynamoDB record exists but its metadata location points to a missing/unreadable metadata JSON (e.g. metadata file already deleted in object storage, bad IO impl config, wrong warehouse path).

Common situations: Manual cleanup of metadata files before dropping the table; a partially deleted table from an earlier failed drop; misconfigured s3.file.io.region or credentials making the metadata file unresolvable and surfacing as NotFoundException.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/80625417ec961ef3. Report an issue: GitHub.

Appendix: source

Thrown at aws/src/main/java/org/apache/iceberg/aws/dynamodb/DynamoDbCatalog.java:396

      GetItemResponse response =
          dynamo.getItem(
              GetItemRequest.builder()
                  .tableName(awsProperties.dynamoDbTableName())
                  .consistentRead(true)
                  .key(key)
                  .build());

      if (!response.hasItem()) {
        throw new NoSuchTableException("Cannot find table %s to drop", identifier);
      }

      TableOperations ops = newTableOps(identifier);
      TableMetadata lastMetadata = null;
      if (purge) {
        try {
          lastMetadata = ops.current();
        } catch (NotFoundException e) {
          LOG.warn(
              "Failed to load table metadata for table: {}, continuing drop without purge",
              identifier,
              e);
        }
      }
      dynamo.deleteItem(
          DeleteItemRequest.builder()
              .tableName(awsProperties.dynamoDbTableName())
              .key(tablePrimaryKey(identifier))
              .conditionExpression(COL_VERSION + " = :v")
              .expressionAttributeValues(ImmutableMap.of(":v", response.item().get(COL_VERSION)))
              .build());
      LOG.info("Successfully dropped table {} from DynamoDb catalog", identifier);

      if (purge && lastMetadata != null) {
        CatalogUtil.dropTableData(ops.io(), lastMetadata);
        LOG.info("Table {} data purged", identifier);
      }

View on GitHub (pinned to 86d9c8fc54)