apache/iceberg · error · RuntimeException

Failed to drop namespace <namespace> in Hive Metastore

Error message

Failed to drop namespace <namespace> in Hive Metastore

What it means

dropNamespace wraps a generic Thrift TException from dropDatabase in a RuntimeException indicating the namespace could not be dropped in the Hive Metastore. Note NoSuchObjectException is handled separately (returns false), so this means an unexpected metastore failure.

Source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:620

                namespace.level(0),
                false /* deleteData */,
                false /* ignoreUnknownDb */,
                false /* cascade */);
            return null;
          });

      LOG.info("Dropped namespace: {}", namespace);
      return true;

    } catch (InvalidOperationException e) {
      throw new NamespaceNotEmptyException(
          e, "Namespace %s is not empty. One or more tables exist.", namespace);

    } catch (NoSuchObjectException e) {
      return false;

    } catch (TException e) {
      throw new RuntimeException("Failed to drop namespace " + namespace + " in Hive Metastore", e);

    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException(
          "Interrupted in call to drop dropDatabase(name) " + namespace + " in Hive Metastore", e);
    }
  }

  @Override
  public boolean setProperties(Namespace namespace, Map<String, String> properties) {
    Preconditions.checkArgument(
        (properties.get(HMS_DB_OWNER_TYPE) == null) == (properties.get(HMS_DB_OWNER) == null),
        "Setting %s and %s has to be performed together or not at all",
        HMS_DB_OWNER_TYPE,
        HMS_DB_OWNER);
    Map<String, String> parameter = Maps.newHashMap();

    parameter.putAll(loadNamespaceMetadata(namespace));

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Inspect the chained cause and verify metastore connectivity and health
  2. Check that the caller has permission to drop the database in Hive/Ranger policies
  3. Retry the drop once the metastore is healthy; check whether the database still exists afterwards
Defensive patterns

Strategy: try-catch

Validate before calling

// ensure privileges and metastore health before dropping
catalog.loadTable(...); // probe connectivity

Try / catch

try {
  catalog.dropNamespace(ns, false);
} catch (RuntimeException e) {
  LOG.error("Drop failed; cause: {}", e.getCause(), e);
  throw e;
}

Prevention

When it happens

Trigger: catalog.dropNamespace(...) when the metastore throws TException — connectivity failure, permissions on the database location, or metastore-side error during dropDatabase.

Common situations: Metastore unreachable mid-operation; insufficient privileges to drop the database or its HDFS location; HDFS/Warehouse path issues during managed-database removal.

Related errors


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