apache/seatunnel · error · DatabaseAlreadyExistException

Database ${databaseName} already exists in catalog ${catalog

Error message

Database ${databaseName} already exists in catalog ${catalogName}

What it means

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().

Source

Thrown at seatunnel-connectors-v2/connector-hudi/src/main/java/org/apache/seatunnel/connectors/seatunnel/hudi/catalog/HudiCatalog.java:282

        } catch (IOException e) {
            throw new CatalogException(String.format("Dropping table %s exception.", tablePath), e);
        }
    }

    @Override
    public void truncateTable(TablePath tablePath, boolean ignoreIfNotExists)
            throws TableNotExistException, CatalogException {
        throw new UnsupportedOperationException("Hudi catalog not support truncate table.");
    }

    @Override
    public void createDatabase(TablePath tablePath, boolean ignoreIfExists)
            throws DatabaseAlreadyExistException, CatalogException {
        if (databaseExists(tablePath.getDatabaseName())) {
            if (ignoreIfExists) {
                return;
            } else {
                throw new DatabaseAlreadyExistException(catalogName, tablePath.getDatabaseName());
            }
        }

        Path dbPath = new Path(tableParentDfsPath, tablePath.getDatabaseName());
        try {
            fs.mkdirs(dbPath);
        } catch (IOException e) {
            throw new CatalogException(
                    String.format("Creating database %s exception.", tablePath.getDatabaseName()),
                    e);
        }
    }

    @Override
    public void dropDatabase(TablePath tablePath, boolean ignoreIfNotExists)
            throws DatabaseNotExistException, CatalogException {
        // do nothing
        if (!databaseExists(tablePath.getDatabaseName())) {

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Pass ignoreIfExists=true for idempotent creation.
  2. Use the existing database instead of creating it.
  3. Remove the stale directory if it should not exist (ensure no tables are needed from it).

Example fix

// before
catalog.createDatabase(TablePath.of("mydb","t"), false); // throws on rerun
// after
catalog.createDatabase(TablePath.of("mydb","t"), true);
Defensive patterns

Strategy: validation

Validate before calling

// Java
if (!catalog.databaseExists(dbName)) {
    catalog.createDatabase(TablePath.of(dbName, "t"), false);
}

Try / catch

// Java
try {
    catalog.createDatabase(tablePath, false);
} catch (DatabaseAlreadyExistException e) {
    // database already present — safe to continue
}

Prevention

When it happens

Trigger: 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.

Common situations: Repeated job submissions that create the database on startup without ignoreIfExists; leftover directory from an earlier run; name collision with an existing namespace.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/f7c21626f123ad90. Report an issue: GitHub.