Skip to content

[server] Prevent deletion of default database to avoid catalog open failure #3311

@gyang94

Description

@gyang94

Search before asking

  • I searched in the issues and found nothing similar.

Description

Summary

Currently, MetadataManager.dropDatabase() does not check whether the database being dropped is the default database (fluss). This allows users to accidentally delete the default database, which causes Flink Catalog to fail to open with:

The configured default-database 'fluss' does not exist in the Fluss cluster.

Furthermore, restarting CoordinatorServer will not recreate the default database, because createDefaultDatabase() only creates it when
databases.isEmpty() returns true — if other databases exist, the default database is never recreated.

Steps to Reproduce

  1. Create a Fluss cluster (default database fluss is auto-created)
  2. Create another database (e.g., my_db)
  3. Drop the default database: DROP DATABASE fluss
  4. Try to open Flink Catalog with 'default-database' = 'fluss' → fails
  5. Restart CoordinatorServer → default database is not recreated (because my_db still exists)

Expected Behavior

dropDatabase() should reject attempts to delete the default database with a clear error message, e.g.:

Caused by: org.apache.flink.table.catalog.exceptions.CatalogException: The configured default-database 'fluss' does not exist in the Fluss cluster.
at org.apache.fluss.flink.catalog.FlinkCatalog.open(FlinkCatalog.java:151)

Proposed Fix

Add a check in MetadataManager.dropDatabase() before proceeding with deletion:

public void dropDatabase(String name, boolean ignoreIfNotExists, boolean cascade)
          throws DatabaseNotExistException, DatabaseNotEmptyException {
      if (CoordinatorServer.DEFAULT_DATABASE.equals(name)) {
          throw new UnsupportedOperationException(
                  "Cannot drop the default database '" + name
                          + "'. The default database is required for cluster operation.");
      }
      // ... existing logic
  }

Willingness to contribute

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions