Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry logic in JDBC catalog fails with class cast exception if driver exception class does not extend SQLTransientException #11176

Open
1 of 3 tasks
asolovey opened this issue Sep 20, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@asolovey
Copy link

Apache Iceberg version

1.6.1 (latest release)

Query engine

None

Please describe the bug 🐞

If retryable error codes are configured, and JDBC catalog connection pool tries to retry action more than once (for example, when database is restarting), it fails with ClassCastException if the JDBC driver exception class does not extend SQLTransientException.

Issue stack trace:

java.lang.ClassCastException: Cannot cast org.postgresql.util.PSQLException to java.sql.SQLTransientException

at java.lang.Class.cast(Class.java:3890)
at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:85)
at org.apache.iceberg.ClientPoolImpl.run(ClientPoolImpl.java:65)
at org.apache.iceberg.jdbc.JdbcUtil.tableOrView(JdbcUtil.java:598)
....

The problem is that in ClientPoolImpl line 85 (https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/core/src/main/java/org/apache/iceberg/ClientPoolImpl.java#L85), there is unconditional cast of the driver exception to reconnectExc, which JdbcClientPool sets to SQLTransientException in the call to superclass (ClientPoolImpl) constructor: https://github.com/apache/iceberg/blob/apache-iceberg-1.6.1/core/src/main/java/org/apache/iceberg/jdbc/JdbcClientPool.java#L69

Postgresql JDBC driver uses PSQLException for all exceptions and this class does not extend SQLTransientException so the cast fails.

Willingness to contribute

  • I can contribute a fix for this bug independently
  • I would be willing to contribute a fix for this bug with guidance from the Iceberg community
  • I cannot contribute a fix for this bug at this time
@asolovey asolovey added the bug Something isn't working label Sep 20, 2024
@nqvuong1998
Copy link

cc @RussellSpitzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants