{"record":{"id":"0ea4c07cbfec11bb","repo":"apache/seatunnel","slug":"failed-to-create-database-databasename","errorCode":null,"errorMessage":"Failed to create database: ${databaseName}","messagePattern":"Failed to create 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":670,"sourceCode":"            throws TableNotExistException, CatalogException {\n        if (!tableExists(tablePath) && !ignoreIfNotExists) {\n            throw new TableNotExistException(\"hive\", tablePath);\n        }\n        if (tableExists(tablePath)) {\n            dropTable(tablePath.getDatabaseName(), tablePath.getTableName());\n        }\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        try {\n            createDatabaseIfNotExists(tablePath.getDatabaseName());\n        } catch (TException e) {\n            if (e instanceof AlreadyExistsException && !ignoreIfExists) {\n                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        }","sourceCodeStart":652,"sourceCodeEnd":688,"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#L652-L688","documentation":"Generic CatalogException thrown by HiveMetaStoreCatalog.createDatabase when the metastore call fails for any reason other than a benign AlreadyExistsException (e.g. connectivity or Thrift errors). It wraps the original TException as the cause.","triggerScenarios":"createDatabase cannot reach the Hive Metastore (network down, wrong metastore URI), the Thrift call throws a non-AlreadyExists TException, or authentication/authorization to the metastore fails.","commonSituations":"Metastore service is down or unreachable; kerberos/login issues; firewall blocking the metastore thrift port; metastore schema mismatch after a Hive version upgrade.","solutions":["Inspect the wrapped cause (getCause()) for the real TException message","Verify the Hive Metastore URI and that the service is reachable (telnet/nc the thrift port)","Check kerberos settings (hive-site.xml, keytab/principal) if the cluster is secured","Retry after fixing connectivity; ensure Hive and SeaTunnel Hive connector versions are compatible"],"exampleFix":"// before\ntry { catalog.createDatabase(tablePath, false); }\ncatch (Exception e) { log.error(\"failed\", e); }\n// after\ntry { catalog.createDatabase(tablePath, true); }\ncatch (DatabaseAlreadyExistException e) { /* ok */ }\ncatch (CatalogException e) { throw new RuntimeException(\"Metastore call failed: \" + e.getCause(), e); }","handlingStrategy":"try-catch","validationCode":"// preflight: try connecting to metastore\nhiveConf.addResource(new Path(hiveSitePath)); // then attempt a light call e.g. getAllDatabases()","typeGuard":"null","tryCatchPattern":"try { catalog.createDatabase(tablePath, true); } catch (CatalogException e) { throw new RuntimeException(\"Metastore failure: \" + e.getCause(), e); }","preventionTips":["Monitor metastore URI reachability before submitting jobs","Log the wrapped cause, not just the wrapper","Validate kerberos config early","Keep Hive metastore and connector Thrift versions compatible"],"tags":["hive","catalog","metastore"],"backgroundTag":"database-query-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}