apache/seatunnel · error · CatalogException

Failed to drop database

Error message

Failed to drop database: ${databaseName}

What it means

Generic CatalogException thrown by HiveMetaStoreCatalog.dropDatabase when the metastore drop operation fails with a TException unrelated to the database being absent (e.g. connectivity, permission, or dependent-table errors). The original TException is preserved as the cause.

Solutions

  1. Check the wrapped cause for the underlying TException message
  2. Grant the connected principal DROP privileges or run as a metastore admin
  3. Drop or cascade the database's tables (client.dropDatabase(name, true, false, true) semantics) before retrying
  4. Verify metastore connectivity and re-authenticate if kerberos was involved

Example fix

// before
catalog.dropDatabase(tablePath, false); // fails if db has tables / no perms
// after
try { catalog.dropDatabase(tablePath, true); }
catch (CatalogException e) { throw new RuntimeException("Drop failed: " + e.getCause(), e); }
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight metastore auth/connectivity
client.getAllDatabases(); // throws TException early if unreachable/unauthorized

Type guard

null

Try / catch

try { catalog.dropDatabase(tablePath, false); } catch (CatalogException e) { throw new RuntimeException("Drop failed: " + e.getCause(), e); }

Prevention

When it happens

Trigger: getClient().dropDatabase(...) throws (metastore unreachable, user lacks DROP privilege, cascade=false and database is non-empty depending on metastore behavior, Thrift timeout).

Common situations: Metastore outage or network partition; insufficient Hive authorization (no admin/drop rights); attempting to drop a database that still contains tables without cascade; kerberos token expiry.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/0974f9b09ffdee2f. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java:686

                throw new DatabaseAlreadyExistException("hive", tablePath.getDatabaseName());
            }
            throw new CatalogException(
                    "Failed to create database: " + tablePath.getDatabaseName(), e);
        }
    }

    @Override
    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)
            throws DatabaseNotExistException, CatalogException {
        try {
            if (!databaseExists(tablePath.getDatabaseName()) && !ignoreIfNotExists) {
                throw new DatabaseNotExistException("hive", tablePath.getDatabaseName());
            }
            if (databaseExists(tablePath.getDatabaseName())) {
                getClient().dropDatabase(tablePath.getDatabaseName());
            }
        } catch (TException e) {
            throw new CatalogException(
                    "Failed to drop database: " + tablePath.getDatabaseName(), e);
        }
    }

    @Override
    public synchronized void close() throws CatalogException {
        if (Objects.nonNull(hiveClient)) {
            hiveClient.close();
        }
    }

    private void maybeRelogin() {
        if (userGroupInformation == null) {
            return;
        }
        try {
            if (userGroupInformation.isFromKeytab()) {
                userGroupInformation.checkTGTAndReloginFromKeytab();

View on GitHub (pinned to cf67b549a7)