Skip to content

[JDBC] Respect interrupt while waiting for engine launch#7527

Open
ruanwenjun wants to merge 3 commits into
apache:masterfrom
ruanwenjun:kyuubi-jdbc-interrupt-launch
Open

[JDBC] Respect interrupt while waiting for engine launch#7527
ruanwenjun wants to merge 3 commits into
apache:masterfrom
ruanwenjun:kyuubi-jdbc-interrupt-launch

Conversation

@ruanwenjun

Copy link
Copy Markdown
Member

Why are the changes needed?

JDBC clients can block inside KyuubiConnection construction while waiting for engine launch. If the caller cancels that connection attempt with Thread.interrupt(), the wait loop previously kept polling and the caller still had no returned Connection object to close.

This patch makes the launch wait path honor interruption by converting it to a typed JDBC exception, KyuubiInterruptedException. The interrupt status is intentionally consumed before the exception reaches the caller, and comments explain that the caller receives the typed exception while the current thread is not interrupted.

The patch also keeps SQLException subclasses intact when KyuubiDataSource creates a connection, so callers can distinguish the interrupted launch path.

How was this patch tested?

  • ./build/mvn -pl kyuubi-hive-jdbc -am spotless:apply
  • ./build/mvn -pl kyuubi-hive-jdbc -am -Dtest=KyuubiConnectionTest,KyuubiStatementTest,TestJdbcDriver,TestKyuubiPreparedStatement,UtilsTest,ZooKeeperHiveClientHelperTest -DwildcardSuites=none test
  • git diff --check

Also attempted dev/reformat, but the full repo reformat is blocked in this local environment because Spotless expects black 22.3.0 while the installed executable is black 25.1.0.

Was this patch authored or co-authored using generative AI tooling?

Assisted-by: OpenAI Codex: GPT-5

@ruanwenjun

Copy link
Copy Markdown
Member Author

PTAL cc @pan3793 @cxzl25

@zhouyifan279

Copy link
Copy Markdown
Contributor

LGTM

@wangzhigang1999

Copy link
Copy Markdown
Contributor

LGTM 👍

Just a nit (non-blocking): isInterrupted(Throwable) and the test's hasCause(...) both hand-roll a cause-chain walk. Since commons-lang3 is already a dependency here (this file already imports StringUtils/ClassUtils from it), we could reuse ExceptionUtils and drop both helpers:

  // import org.apache.commons.lang3.exception.ExceptionUtils;
  ExceptionUtils.indexOfType(e, InterruptedException.class) >= 0

Same semantics, ~20 fewer lines, removes the duplicated logic between main and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment