{"record":{"id":"1622ea2f18858344","repo":"apache/seatunnel","slug":"databasealreadyexistexception-database-databas","errorCode":null,"errorMessage":"DatabaseAlreadyExistException: database '${databaseName}' already exists in catalog '${catalogName}'","messagePattern":"DatabaseAlreadyExistException: database '(.+?)' already exists in catalog '(.+?)'","errorType":"exception","errorClass":"DatabaseAlreadyExistException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/catalog/HbaseCatalog.java","lineNumber":159,"sourceCode":"    @Override\n    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        checkNotNull(tablePath);\n        if (!tableExists(tablePath)) {\n            if (!ignoreIfNotExists) {\n                throw new TableNotExistException(catalogName, tablePath);\n            }\n            return;\n        }\n        hbaseClient.dropTable(tablePath.getDatabaseName(), tablePath.getTableName());\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        if (databaseExists(tablePath.getDatabaseName())) {\n            if (!ignoreIfExists) {\n                throw new DatabaseAlreadyExistException(catalogName, tablePath.getDatabaseName());\n            }\n            return;\n        }\n        hbaseClient.createNamespace(tablePath.getDatabaseName());\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        if (!databaseExists(tablePath.getDatabaseName())) {\n            if (!ignoreIfNotExists) {\n                throw new DatabaseNotExistException(catalogName, tablePath.getDatabaseName());\n            }\n            return;\n        }\n        hbaseClient.deleteNamespace(tablePath.getDatabaseName());\n    }\n","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hbase/src/main/java/org/apache/seatunnel/connectors/seatunnel/hbase/catalog/HbaseCatalog.java#L141-L177","documentation":"Thrown by HbaseCatalog.createDatabase when the target database (HBase namespace) already exists and ignoreIfExists is false. The catalog checks databaseExists before calling hbaseClient.createNamespace.","triggerScenarios":"Calling createDatabase(tablePath, ignoreIfExists=false) for a namespace that already exists in HBase.","commonSituations":"Initialization code executed on every job start without idempotency; namespace created by HBase admin; concurrent jobs creating the same namespace.","solutions":["Pass ignoreIfExists = true to make creation idempotent.","Check existence first with databaseExists before creating.","Remove duplicate initialization logic or guard it with a flag."],"exampleFix":"// before\ncatalog.createDatabase(path, false); // fails on rerun\n// after\ncatalog.createDatabase(path, true); // skip if exists","handlingStrategy":"validation","validationCode":"if (!catalog.databaseExists(tablePath.getDatabaseName())) {\n    catalog.createDatabase(tablePath, false);\n} else {\n    catalog.createDatabase(tablePath, true); // no-op\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.createDatabase(tablePath, false);\n} catch (DatabaseAlreadyExistException e) {\n    LOG.info(\"Namespace {} already exists\", tablePath.getDatabaseName());\n}","preventionTips":["Use ignoreIfExists = true in initialization code that runs on every job start.","Guard namespace creation with databaseExists.","Avoid creating namespaces in multiple places in the pipeline."],"tags":["hbase","catalog","duplicate"],"backgroundTag":"file-already-exists","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"}