{"record":{"id":"f7c21626f123ad90","repo":"apache/seatunnel","slug":"database-databasename-already-exists-in-catalog-f7c216","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-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java","lineNumber":282,"sourceCode":"        } catch (IOException e) {\n            throw new CatalogException(String.format(\"Dropping table %s exception.\", tablePath), e);\n        }\n    }\n\n    @Override\n    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)\n            throws TableNotExistException, CatalogException {\n        throw new UnsupportedOperationException(\"Hudi catalog not support truncate table.\");\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                return;\n            } else {\n                throw new DatabaseAlreadyExistException(catalogName, tablePath.getDatabaseName());\n            }\n        }\n\n        Path dbPath = new Path(tableParentDfsPath, tablePath.getDatabaseName());\n        try {\n            fs.mkdirs(dbPath);\n        } catch (IOException e) {\n            throw new CatalogException(\n                    String.format(\"Creating database %s exception.\", tablePath.getDatabaseName()),\n                    e);\n        }\n    }\n\n    @Override\n    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)\n            throws DatabaseNotExistException, CatalogException {\n        // do nothing\n        if (!databaseExists(tablePath.getDatabaseName())) {","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java#L264-L300","documentation":"Standard DatabaseAlreadyExistException thrown by HudiCatalog.createDatabase() when the database directory already exists under table_parent_dfs_path and ignoreIfExists is false. Since databases are plain directories, existence is checked with databaseExists().","triggerScenarios":"Calling createDatabase(tablePath, false) when a directory with the database name already exists — e.g., during catalog.open() auto-setup or an explicit createDatabase call after the DB was created previously.","commonSituations":"Repeated job submissions that create the database on startup without ignoreIfExists; leftover directory from an earlier run; name collision with an existing namespace.","solutions":["Pass ignoreIfExists=true for idempotent creation.","Use the existing database instead of creating it.","Remove the stale directory if it should not exist (ensure no tables are needed from it)."],"exampleFix":"// before\ncatalog.createDatabase(TablePath.of(\"mydb\",\"t\"), false); // throws on rerun\n// after\ncatalog.createDatabase(TablePath.of(\"mydb\",\"t\"), true);","handlingStrategy":"validation","validationCode":"// Java\nif (!catalog.databaseExists(dbName)) {\n    catalog.createDatabase(TablePath.of(dbName, \"t\"), false);\n}","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n    catalog.createDatabase(tablePath, false);\n} catch (DatabaseAlreadyExistException e) {\n    // database already present — safe to continue\n}","preventionTips":["Always pass ignoreIfExists=true from startup/auto-setup code paths.","Check databaseExists before creating.","Avoid recreating databases on every job submission."],"tags":["hudi","catalog","already-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-14T11:17:12.474Z"}