gyang94 opened a new issue, #3311:
URL: https://github.com/apache/fluss/issues/3311

   ### Search before asking
   
   - [x] I searched in the [issues](https://github.com/apache/fluss/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 InvalidDatabaseException(
                     "Cannot drop the default database '" + name
                             + "'. The default database is required for cluster 
operation.");
         }
         // ... existing logic
     }
   
   ### Willingness to contribute
   
   - [x] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to