Uploaded image for project: 'Agroal'
  1. Agroal
  2. AG-114

Connection failure stack traces are confusing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.5
    • 1.4
    • pool
    • None

      The stack traces for failed connections are not correct due to incorrect handling of exceptions thrown from Future.get(). They include intermediate causes that are not relevant to the problem or any debugging effort.

      Here's an example too-long stack trace:

      java.sql.SQLException: Exception while creating new connection
      	at io.agroal.pool.ConnectionPool.handlerFromSharedCache(ConnectionPool.java:225)
      	at io.agroal.pool.ConnectionPool.getConnection(ConnectionPool.java:146)
      	at io.agroal.pool.DataSource.getConnection(DataSource.java:61)
      	at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
      	at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess.obtainConnection(JdbcEnvironmentInitiator.java:180)
      	at org.hibernate.resource.transaction.backend.jta.internal.DdlTransactionIsolatorJtaImpl.<init>(DdlTransactionIsolatorJtaImpl.java:59)
      	... 20 more
      Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Exception while creating new connection
      	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
      	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
      	at io.agroal.pool.ConnectionPool.handlerFromSharedCache(ConnectionPool.java:193)
      	... 25 more
      Caused by: java.lang.RuntimeException: Exception while creating new connection
      	at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:357)
      	at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:337)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:63)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:481)
      	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
      Caused by: org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-197]
      	at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:451)
      	at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:332)
      	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
      	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:103)
      	at org.h2.Driver.connect(Driver.java:69)
      	at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:178)
      	at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:348)
      	... 8 more
      Caused by: java.net.ConnectException: Connection refused
      	at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:5193)
      	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      	at java.net.Socket.connect(Socket.java:589)
      	at org.h2.util.NetUtils.createSocket(NetUtils.java:103)
      	at org.h2.util.NetUtils.createSocket(NetUtils.java:83)
      	at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
      	at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:447)
      	... 14 more
      

      Here's the preferred output:

      org.h2.jdbc.JdbcSQLException: Connection is broken: "java.net.ConnectException: Connection refused: localhost" [90067-197]
      	at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:451)
      	at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:332)
      	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:124)
      	at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:103)
      	at org.h2.Driver.connect(Driver.java:69)
      	at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:178)
      	at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:355)
      	at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:344)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:63)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at java.lang.Thread.run(Thread.java:748)
      	at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:481)
      	at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:193)
      Caused by: java.net.ConnectException: Connection refused
      	at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:5193)
      	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
      	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
      	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
      	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
      	at java.net.Socket.connect(Socket.java:589)
      	at org.h2.util.NetUtils.createSocket(NetUtils.java:103)
      	at org.h2.util.NetUtils.createSocket(NetUtils.java:83)
      	at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:114)
      	at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:447)
      	... 14 more
      

              dlloyd@redhat.com David Lloyd
              dlloyd@redhat.com David Lloyd
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: