You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "yadavay-amzn (via GitHub)" <gi...@apache.org> on 2026/04/19 09:17:53 UTC
[PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry (#15759) [iceberg]
yadavay-amzn opened a new pull request, #16049:
URL: https://github.com/apache/iceberg/pull/16049
## Summary
In `JdbcLockFactory.JdbcLock`, the `instanceId()` and `unlock()` methods caught `SQLException` inside the lambda passed to `ClientPoolImpl.run()` and wrapped it as `UncheckedSQLException` (a `RuntimeException`). This prevented `ClientPoolImpl`'s retry mechanism from triggering because `isConnectionException()` checks for `SQLException`, not `UncheckedSQLException`.
## Fix
Removed the inner `try-catch` blocks that wrapped `SQLException` as `UncheckedSQLException` inside the lambdas. The lambda signature for `ClientPoolImpl.run()` already declares `throws Exception`, so `SQLException` propagates naturally to `ClientPoolImpl` where the retry logic can detect connection exceptions and retry appropriately.
The outer `catch (SQLException e)` blocks remain to convert to `UncheckedSQLException` after `ClientPoolImpl` has exhausted its retry attempts.
Closes #15759
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry (#15759) [iceberg]
Posted by "pvary (via GitHub)" <gi...@apache.org>.
pvary commented on PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#issuecomment-4303852507
The tests are not failing without the fix. This means that we have no way to prevent regression if a future change reverts this fix. Could you please make sure that we have test case(s) which fail without the fix and green after the fix is applied?
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry [iceberg]
Posted by "pvary (via GitHub)" <gi...@apache.org>.
pvary merged PR #16049:
URL: https://github.com/apache/iceberg/pull/16049
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry (#15759) [iceberg]
Posted by "yadavay-amzn (via GitHub)" <gi...@apache.org>.
yadavay-amzn commented on PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#issuecomment-4347092925
> Can we resolve the CI errors?
@Guosmilesmile Rebased onto latest main. Failure was from
`iceberg-orc:compileTestJava`, unrelated to the Flink changes here. Should be green now.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry (#15759) [iceberg]
Posted by "Guosmilesmile (via GitHub)" <gi...@apache.org>.
Guosmilesmile commented on code in PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#discussion_r3160498769
##########
flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestJdbcLockFactory.java:
##########
@@ -38,4 +45,61 @@ TriggerLockFactory lockFactory(String tableName) {
tableName,
properties);
}
+
+ @Test
+ void testSQLExceptionEnablesRetryInClientPool() throws Exception {
+ // Regression test for #15759: verify that removing the inner try-catch allows
+ // ClientPoolImpl to retry on transient connection failures.
+ //
+ // Before the fix: inner catch converted SQLException -> UncheckedSQLException
+ // (RuntimeException) inside the lambda. ClientPoolImpl only catches the declared
+ // exception type (SQLException), so RuntimeException bypasses retry entirely.
+ // After the fix: SQLException propagates naturally, ClientPoolImpl catches it,
+ // and retries on transient connection exceptions.
+ Map<String, String> props = Maps.newHashMap();
+ props.put("username", "user");
+ props.put("password", "password");
+ String uri = "jdbc:sqlite:file::memory:?ic" + UUID.randomUUID().toString().replace("-", "");
+
+ try (JdbcClientPool pool = new JdbcClientPool(1, uri, props)) {
+ AtomicInteger attempts = new AtomicInteger(0);
+
+ String result =
+ pool.run(
+ conn -> {
+ if (attempts.incrementAndGet() == 1) {
+ throw new SQLTransientConnectionException("transient failure");
+ }
+ return "success";
Review Comment:
nit: newline.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry [iceberg]
Posted by "pvary (via GitHub)" <gi...@apache.org>.
pvary commented on PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#issuecomment-4352233891
Merged to main.
Thanks @yadavay-amzn for the fix and @Guosmilesmile for the review!
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry (#15759) [iceberg]
Posted by "yadavay-amzn (via GitHub)" <gi...@apache.org>.
yadavay-amzn commented on PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#issuecomment-4306269328
Updated. The new tests directly demonstrate the retry behavior difference:
- `testSQLExceptionEnablesRetryInClientPool`: lambda throws `SQLTransientConnectionException` on first call, succeeds on retry. Passes only when `SQLException` propagates naturally (fix applied).
- `testUncheckedSQLExceptionBypassesRetry`: same exception wrapped as `UncheckedSQLException` (old behavior) — `ClientPoolImpl` cannot catch `RuntimeException`, so no retry happens.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org
Re: [PR] Flink: Fix JdbcLockFactory to allow ClientPoolImpl connection retry (#15759) [iceberg]
Posted by "yadavay-amzn (via GitHub)" <gi...@apache.org>.
yadavay-amzn commented on code in PR #16049:
URL: https://github.com/apache/iceberg/pull/16049#discussion_r3163786521
##########
flink/v1.20/flink/src/test/java/org/apache/iceberg/flink/maintenance/api/TestJdbcLockFactory.java:
##########
@@ -38,4 +45,61 @@ TriggerLockFactory lockFactory(String tableName) {
tableName,
properties);
}
+
+ @Test
+ void testSQLExceptionEnablesRetryInClientPool() throws Exception {
+ // Regression test for #15759: verify that removing the inner try-catch allows
+ // ClientPoolImpl to retry on transient connection failures.
+ //
+ // Before the fix: inner catch converted SQLException -> UncheckedSQLException
+ // (RuntimeException) inside the lambda. ClientPoolImpl only catches the declared
+ // exception type (SQLException), so RuntimeException bypasses retry entirely.
+ // After the fix: SQLException propagates naturally, ClientPoolImpl catches it,
+ // and retries on transient connection exceptions.
+ Map<String, String> props = Maps.newHashMap();
+ props.put("username", "user");
+ props.put("password", "password");
+ String uri = "jdbc:sqlite:file::memory:?ic" + UUID.randomUUID().toString().replace("-", "");
+
+ try (JdbcClientPool pool = new JdbcClientPool(1, uri, props)) {
+ AtomicInteger attempts = new AtomicInteger(0);
+
+ String result =
+ pool.run(
+ conn -> {
+ if (attempts.incrementAndGet() == 1) {
+ throw new SQLTransientConnectionException("transient failure");
+ }
+ return "success";
Review Comment:
Done.
--
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: issues-unsubscribe@iceberg.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org