Description
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