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

   ### What changes were proposed in this pull request?
   
   - `BoundedConnectionDriver` interrupts an abandoned attempt's worker from a 
separate daemon cancellation pool instead of the request thread.
   - The interrupt is delivered only while the worker is inside 
`Driver#connect`. When `connect` returns, the worker waits for an in-flight 
interrupt to finish before moving on, so it cannot reach a later attempt that 
reuses the same pooled worker.
   - Abandoned attempts and attempts that finish after abandonment are logged; 
rejected attempts are aggregated into at most one log line a minute. Logs name 
the driver class, not the URL.
   - Add `JdbcCatalogOperations#configureDataSource(DataSource, JdbcConfig)`, a 
protected hook (default no-op) called before the first connection is borrowed. 
`dataSource` is private and DBCP only honours `setDriver` before the pool is 
created, so a JDBC catalog whose driver does not enforce a login timeout has no 
other clean point to install `BoundedConnectionDriver`. If the hook throws, the 
data source is closed and initialization fails.
   - Update `docs/jdbc-catalog-connection-validation.md`.
   
   ### Why are the changes needed?
   
   `Thread.interrupt()` can synchronously run a driver's interrupt callback, 
such as closing an `InterruptibleChannel`. When it runs on the request thread 
and blocks, the caller stays blocked past the connection deadline the adapter 
enforces.
   
   Fixes #14761
   
   ### Does this PR introduce _any_ user-facing change?
   
   No API or configuration change; a new protected extension point. Limits, 
documented:
   - Blocking `java.net` socket I/O is not interruptible on JDK 17, so a driver 
blocked in a socket connect or read keeps its worker until its own socket 
timeout.
   - A driver or close that never returns keeps its worker (and, if the 
interrupt callback never returns, one cancellation thread) until the server 
restarts.
   - If a cancellation is rejected, the worker is not interrupted and a warning 
is logged.
   
   ### How was this patch tested?
   
   - `TestBoundedConnectionDriver` (20 tests). New or changed tests cover: the 
blocking interrupt callback running on the cancellation thread rather than the 
caller; an interruptible hung driver releasing its worker; an in-flight 
interrupt not reaching the next attempt on the same worker; a cancellation 
after `connect` returned not interrupting late-connection cleanup. Removing the 
respective guard makes each of the last two fail.
   - `TestJdbcCatalogOperationsDataSourceHook`: the hook runs before the first 
borrow (including a connector that borrows to read the driver version) and its 
driver is used; a failing hook closes the data source and propagates; the 
default keeps the configured driver. Moving the hook after the first borrow, or 
removing the close, makes a test fail.
   - `catalog-jdbc-common` unit tests (172) pass.
   


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