Igor Berman created CALCITE-5467:
------------------------------------

             Summary: Runtime exception after failure of opening connection is 
not converted into SQLException
                 Key: CALCITE-5467
                 URL: https://issues.apache.org/jira/browse/CALCITE-5467
             Project: Calcite
          Issue Type: Bug
          Components: avatica
            Reporter: Igor Berman


If for any reason connection creation is failing the Runtime exception is 
propagated as is, but should be wrapped with SQLException as was partially done 
for some usecases in https://github.com/apache/calcite-avatica/pull/33/files 

the effect of current behavior might cause "connection leaks", if avatica 
connections are wrapped with some connection pools(e.g. HikariCP). Since most 
of the pool solution handle SQLException but might not handle 
RuntimeExceptions. 

here is stacktrace as an example of such case:
{code}
Caused by: java.lang.RuntimeException: Failed to execute HTTP Request, got 
HTTP/504
        at 
org.apache.calcite.avatica.remote.AvaticaCommonsHttpClientImpl.send(AvaticaCommonsHttpClientImpl.java:229)
 ~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.remote.RemoteProtobufService._apply(RemoteProtobufService.java:44)
 ~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.remote.ProtobufService.apply(ProtobufService.java:89)
 ~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.remote.RemoteMeta$5.call(RemoteMeta.java:149) 
~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.remote.RemoteMeta$5.call(RemoteMeta.java:135) 
~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.AvaticaConnection.invokeWithRetries(AvaticaConnection.java:793)
 ~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.remote.RemoteMeta.connectionSync(RemoteMeta.java:134)
 ~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.AvaticaConnection.sync(AvaticaConnection.java:726) 
~[avatica-core-1.17.0.jar:1.17.0]
        at 
org.apache.calcite.avatica.AvaticaConnection.getAutoCommit(AvaticaConnection.java:195)
 ~[avatica-core-1.17.0.jar:1.17.0]
        at sun.reflect.GeneratedMethodAccessor120.invoke(Unknown Source) ~[?:?]
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 ~[?:1.8.0_302]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_302]
        at 
com.github.gquintana.metrics.proxy.MethodInvocation.proceed(MethodInvocation.java:75)
 ~[metrics-sql-3.1.0-taboola.jar:?]
        at 
com.github.gquintana.metrics.sql.ConnectionProxyHandler.invoke(ConnectionProxyHandler.java:59)
 ~[metrics-sql-3.1.0-taboola.jar:?]
        at 
com.github.gquintana.metrics.proxy.ProxyHandler.invoke(ProxyHandler.java:56) 
~[metrics-sql-3.1.0-taboola.jar:?]
        at com.sun.proxy.$Proxy70.getAutoCommit(Unknown Source) ~[?:?]
        at 
com.zaxxer.hikari.pool.HikariProxyConnection.getAutoCommit(HikariProxyConnection.java)
 ~[HikariCP-3.3.1.jar:?]
{code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to