{"record":{"id":"fa2bc311e2b5f9fa","repo":"apache/seatunnel","slug":"database-databasename-already-exists-in-catalog-fa2bc3","errorCode":null,"errorMessage":"Database ${databaseName} already exists in catalog ${catalogName}","messagePattern":"Database (.+?) already exists in catalog (.+?)","errorType":"exception","errorClass":"DatabaseAlreadyExistException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java","lineNumber":209,"sourceCode":"    }\n\n    @Override\n    public void dropTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        try {\n            catalog.dropTable(toIdentifier(tablePath), ignoreIfNotExists);\n        } catch (org.apache.paimon.catalog.Catalog.TableNotExistException e) {\n            throw new TableNotExistException(this.catalogName, tablePath);\n        }\n    }\n\n    @Override\n    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)\n            throws DatabaseAlreadyExistException, CatalogException {\n        try {\n            catalog.createDatabase(tablePath.getDatabaseName(), ignoreIfExists);\n        } catch (org.apache.paimon.catalog.Catalog.DatabaseAlreadyExistException e) {\n            throw new DatabaseAlreadyExistException(this.catalogName, tablePath.getDatabaseName());\n        }\n    }\n\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        try {\n            Identifier identifier = toIdentifier(tablePath);\n            FileStoreTable table = (FileStoreTable) catalog.getTable(identifier);\n            Schema schema = buildPaimonSchema(table.schema());\n            dropTable(tablePath, ignoreIfNotExists);\n            catalog.createTable(identifier, schema, ignoreIfNotExists);\n        } catch (org.apache.paimon.catalog.Catalog.TableNotExistException e) {\n            throw new TableNotExistException(this.catalogName, tablePath);\n        } catch (org.apache.paimon.catalog.Catalog.TableAlreadyExistException e) {\n            throw new DatabaseAlreadyExistException(this.catalogName, tablePath.getDatabaseName());\n        } catch (org.apache.paimon.catalog.Catalog.DatabaseNotExistException e) {\n            throw new DatabaseNotExistException(this.catalogName, tablePath.getDatabaseName());","sourceCodeStart":191,"sourceCodeEnd":227,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/catalog/PaimonCatalog.java#L191-L227","documentation":"Thrown by PaimonCatalog.createDatabase when the underlying Paimon catalog reports that the target database already exists and ignoreIfExists=false. SeaTunnel wraps Paimon's Catalog.DatabaseAlreadyExistException into its own DatabaseAlreadyExistException, carrying the SeaTunnel catalog name and database name.","triggerScenarios":"Calling createDatabase(tablePath, false) (e.g. auto-create logic during sink setup) when the database already exists in the Paimon warehouse; also occurs when the catalog is backed by a shared metastore (Hive/HDFS) where another job created the same database.","commonSituations":"Multiple jobs or retries racing to auto-create the same database; running a job twice without cleaning the warehouse path; typo'd or reused databaseName from config; Hive metastore still holding the db after warehouse files were deleted.","solutions":["Pass ignoreIfExists=true if the database existing is acceptable","Drop the existing database first (dropDatabase) or pick a different databaseName in table_path","Verify warehouse/metastore state and remove stale database metadata if it is orphaned","Serialize initialization across concurrent jobs that auto-create the same database"],"exampleFix":"// before\ncatalog.createDatabase(tablePath, false);\n// after\ncatalog.createDatabase(tablePath, true); // or pre-check: if (!catalog.databaseExists(tablePath.getDatabaseName())) ...","handlingStrategy":"try-catch","validationCode":"if (!catalog.databaseExists(tablePath.getDatabaseName())) {\n    catalog.createDatabase(tablePath, false);\n}","typeGuard":null,"tryCatchPattern":"try {\n    catalog.createDatabase(tablePath, ignoreIfExists);\n} catch (DatabaseAlreadyExistException e) {\n    LOG.warn(\"database {} already exists, skipping\", tablePath.getDatabaseName());\n}","preventionTips":["Prefer ignoreIfExists=true for idempotent job startup","Pre-check databaseExists before creating","Avoid multiple jobs auto-creating the same database concurrently","Use unique database names per environment/pipeline"],"tags":["paimon","catalog","database-exists"],"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-23T08:17:48.524Z"}