{"record":{"id":"0974f9b09ffdee2f","repo":"apache/seatunnel","slug":"failed-to-drop-database-databasename","errorCode":null,"errorMessage":"Failed to drop database: ${databaseName}","messagePattern":"Failed to drop database: (.+?)","errorType":"exception","errorClass":"CatalogException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java","lineNumber":686,"sourceCode":"                throw new DatabaseAlreadyExistException(\"hive\", tablePath.getDatabaseName());\n            }\n            throw new CatalogException(\n                    \"Failed to create database: \" + tablePath.getDatabaseName(), e);\n        }\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        try {\n            if (!databaseExists(tablePath.getDatabaseName()) && !ignoreIfNotExists) {\n                throw new DatabaseNotExistException(\"hive\", tablePath.getDatabaseName());\n            }\n            if (databaseExists(tablePath.getDatabaseName())) {\n                getClient().dropDatabase(tablePath.getDatabaseName());\n            }\n        } catch (TException e) {\n            throw new CatalogException(\n                    \"Failed to drop database: \" + tablePath.getDatabaseName(), e);\n        }\n    }\n\n    @Override\n    public synchronized void close() throws CatalogException {\n        if (Objects.nonNull(hiveClient)) {\n            hiveClient.close();\n        }\n    }\n\n    private void maybeRelogin() {\n        if (userGroupInformation == null) {\n            return;\n        }\n        try {\n            if (userGroupInformation.isFromKeytab()) {\n                userGroupInformation.checkTGTAndReloginFromKeytab();","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/utils/HiveMetaStoreCatalog.java#L668-L704","documentation":"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.","triggerScenarios":"getClient().dropDatabase(...) throws (metastore unreachable, user lacks DROP privilege, cascade=false and database is non-empty depending on metastore behavior, Thrift timeout).","commonSituations":"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.","solutions":["Check the wrapped cause for the underlying TException message","Grant the connected principal DROP privileges or run as a metastore admin","Drop or cascade the database's tables (client.dropDatabase(name, true, false, true) semantics) before retrying","Verify metastore connectivity and re-authenticate if kerberos was involved"],"exampleFix":"// before\ncatalog.dropDatabase(tablePath, false); // fails if db has tables / no perms\n// after\ntry { catalog.dropDatabase(tablePath, true); }\ncatch (CatalogException e) { throw new RuntimeException(\"Drop failed: \" + e.getCause(), e); }","handlingStrategy":"try-catch","validationCode":"// preflight metastore auth/connectivity\nclient.getAllDatabases(); // throws TException early if unreachable/unauthorized","typeGuard":"null","tryCatchPattern":"try { catalog.dropDatabase(tablePath, false); } catch (CatalogException e) { throw new RuntimeException(\"Drop failed: \" + e.getCause(), e); }","preventionTips":["Ensure the principal has DROP privilege on the database","Empty/cascade child tables before dropping","Handle metastore outages with retry with backoff","Check kerberos ticket validity for long-running jobs"],"tags":["hive","catalog","metastore"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}