dennismdejong opened a new pull request, #13709:
URL: https://github.com/apache/gravitino/pull/13709

   
   ### What changes were proposed in this pull request?
   
   `JdbcTableOperations.alterTable` now passes its execution `Connection` to
   `generateAlterTableSql`, which forwards it to `getOrCreateTable` and to a new
   connection-aware `load(Connection, databaseName, tableName)` overload. Every
   JDBC catalog (MySQL, Doris, PostgreSQL, StarRocks, ClickHouse, Hologres,
   OceanBase) reuses that connection to read the original table definition 
instead
   of borrowing a second connection from the pool.
   
   The public `load(String, String)` contract is unchanged; it still borrows and
   delegates. ClickHouse keeps its specialized `load` body by moving it into the
   connection-aware overload.
   
   ### Why are the changes needed?
   
   `alterTable` obtained a connection before calling `generateAlterTableSql`. 
The
   generators call `getOrCreateTable` to keep Gravitino's identifier in comments
   and to build column definitions, and `getOrCreateTable` called `load`, which
   borrowed a second connection. With the default pool size of 10, 32 concurrent
   ALTERs on distinct tables consumed every pool slot with outer connections and
   then blocked waiting for another connection inside SQL generation, failing 
with
   `Cannot get a connection, pool error Timeout waiting for idle object,
   borrowMaxWaitDuration=PT30S`. No same-table contention was required.
   
   Fix: #13591
   
   ### Does this PR introduce _any_ user-facing change?
   
   No. The generated SQL is unchanged; only the connection used for metadata
   lookups changes from a newly borrowed one to the caller's.
   
   ### How was this patch tested?
   
   Added `TestJdbcTableOperationsConnectionReuse` in `catalog-jdbc-common`. It 
wraps
   a SQLite `DataSource` so that a second `getConnection()` while a connection 
is
   checked out fails fast, then asserts `alterTable` borrows exactly one 
connection,
   never holds more than one at a time, and still executes the generated 
statement.
   The probe was verified to fail against the previous (borrowing) behaviour 
and to
   pass with the fix.
   
   `compileJava`, `compileTestJava`, `spotlessCheck` and the unit tests of
   `catalog-jdbc-common`, `catalog-jdbc-{mysql,doris,postgresql,starrocks}` and 
the
   contrib modules `catalog-jdbc-{clickhouse,hologres,oceanbase}` pass. 
Existing SQL
   generation tests were updated for the new protected signatures.
   


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