geyanggang opened a new issue, #13767:
URL: https://github.com/apache/gravitino/issues/13767

   ### What would you like to be improved?
   
   Creating a relational JDBC catalog returns success without checking that the 
backend is reachable, and the behavior is not consistent across providers. An 
administrator who mistypes a host, port, or credential gets a success response 
and a catalog that does not work; the failure then surfaces later on an 
unrelated operation.
   
   The cause is that CatalogManager.createCatalog performs no connection check 
— whether the backend is touched during create depends entirely on each 
connector's initialize() side effects. JDBC catalogs build a lazy DBCP2 
connection pool (DataSourceUtils.createDBCPDataSource, with initialSize 
blocked), so create opens no connection and never reaches the backend. The 
existing BaseCatalog.shouldValidateOnCreate() hook only eagerly calls ops(), 
which for JDBC still opens no connection, so even opting in does not verify 
reachability.
   
   There is also no bounded JDBC connect/socket timeout: JdbcConfig exposes 
only pool settings and DataSourceUtils sets only the pool maxWait, so a 
connection attempt against an unreachable host can block for the driver default 
(effectively unbounded for the MySQL-family default connectTimeout=0).
   
   As a result the API silently differs per provider, and the administrator 
gets no signal at the point where the mistake is cheap to fix.
   
   ### How should we improve?
   
   - Add a bounded JDBC connect/socket timeout in catalog-jdbc-common (a 
jdbc.pool.connect-timeout-ms setting plus a small driver-aware translator that 
maps it to each driver's connection parameters, since the parameter unit 
differs — e.g. MySQL Connector/J uses milliseconds, PostgreSQL uses seconds), 
so a verification against an unreachable host fails fast.
   - Have JDBC catalogs verify the backend at create by performing a real 
testConnection (a listDatabases round trip) on the existing create-time 
validation path, instead of only eager ops(). On failure, the existing create 
rollback removes the persisted entity, and the caller receives a 
connection-failed error naming the host and the driver message.
   - Add a registered, hidden catalog property 
gravitino.catalog.verify-on-create (default true) so an administrator can 
explicitly register a catalog whose backend is temporarily unavailable.
   - Keep this scoped to JDBC providers. Iceberg REST already validates 
selectively via shouldValidateOnCreate(), and model/generic catalogs do not 
support testConnection, so they remain exempt.
   - Document the create-time verification behavior and the override.


-- 
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