[jboss-jira] [JBoss JIRA] (WFLY-12315) SQLException.getSQLState() and getCause() are null with XADatasource connection for postgresql during network failure

Ivo Studensky (Jira) issues at jboss.org
Tue Jul 23 09:08:01 EDT 2019


     [ https://issues.jboss.org/browse/WFLY-12315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ivo Studensky moved JBEAP-17244 to WFLY-12315:
----------------------------------------------

              Project: WildFly  (was: JBoss Enterprise Application Platform)
                  Key: WFLY-12315  (was: JBEAP-17244)
             Workflow: GIT Pull Request workflow   (was: CDW with loose statuses v1)
          Component/s: JCA
                           (was: JCA)
    Affects Version/s:     (was: 7.2.2.GA)
        Fix Version/s:     (was: 7.2.4.GA)


> SQLException.getSQLState() and getCause() are null with XADatasource connection for postgresql during network failure
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: WFLY-12315
>                 URL: https://issues.jboss.org/browse/WFLY-12315
>             Project: WildFly
>          Issue Type: Bug
>          Components: JCA
>            Reporter: Ivo Studensky
>            Assignee: Ivo Studensky
>            Priority: Major
>
> When using staled connection of xa datasource, the connection throws SQLException.
> Then SQLException.getSQLState() and getCause() returns null if using XA datasource.
> The SQLException is re-created in the following stack.
> {code}
> #####: java.sql.SQLException: Error
> 	at org.jboss.jca.adapters.jdbc.WrappedConnection.checkException(WrappedConnection.java:2033)
> 	at org.jboss.jca.adapters.jdbc.WrappedStatement.checkException(WrappedStatement.java:1436)
> 	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:509)
> 	at com.example.SelectXaServlet.doGet(SelectXaServlet.java:41)
> {code}
> - adapters/src/main/java/org/jboss/jca/adapters/jdbc/WrappedConnection.java
> {code}
>    protected SQLException checkException(Throwable t) throws SQLException
>    {
>       Throwable result = null;
>       if (t instanceof AbstractMethodError)
>       {
>          t = new SQLFeatureNotSupportedException(bundle.methodNotImplemented(), t);
>       }
>       if (mc != null)
>          result = mc.connectionError(t);
>       if (result instanceof SQLException)
>       {
>          throw (SQLException) result;
>       }
>       else
>       {
>          throw new SQLException("Error", result); // If the managed connection is null, create a new SQLException.
>       }
>    }
> {code}
> In the above, the managed connection is null.
> This is because that the ConnectionEventListener#connectionErrorOccurred() fired by the Postgresql driver.
> (oracle driver doesn't fire the event during executing statement, so this issue doen't occur.)
> {code}
> 	at org.jboss.jca.adapters.jdbc.WrappedConnection.setManagedConnection(WrappedConnection.java:120) // null set
> 	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.cleanup(BaseWrapperManagedConnection.java:339)
> 	- locked <0x00000000f9ea3560> (a java.util.HashSet)
> 	at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.returnConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:666)
> 	at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreConcurrentLinkedDequeManagedConnectionPool.returnConnection(SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:611)
> 	at org.jboss.jca.core.connectionmanager.pool.AbstractPool.returnConnection(AbstractPool.java:847)
> 	at org.jboss.jca.core.connectionmanager.AbstractConnectionManager.returnManagedConnection(AbstractConnectionManager.java:725)
> 	at org.jboss.jca.core.connectionmanager.listener.AbstractConnectionListener.connectionErrorOccurred(AbstractConnectionListener.java:472)
> 	at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.broadcastConnectionError(BaseWrapperManagedConnection.java:673)
> 	at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection.broadcastConnectionError(XAManagedConnection.java:203)
> 	at org.jboss.jca.adapters.jdbc.xa.XAManagedConnection$1.connectionErrorOccurred(XAManagedConnection.java:91)
> 	at org.postgresql.ds.PGPooledConnection.fireConnectionFatalError(PGPooledConnection.java:183)
> 	at org.postgresql.ds.PGPooledConnection.fireConnectionError(PGPooledConnection.java:237)
> 	at org.postgresql.ds.PGPooledConnection.access$200(PGPooledConnection.java:38)
> 	at org.postgresql.ds.PGPooledConnection$StatementHandler.invoke(PGPooledConnection.java:428)
> 	at com.sun.proxy.$Proxy64.executeQuery(Unknown Source)
> 	at org.jboss.jca.adapters.jdbc.WrappedPreparedStatement.executeQuery(WrappedPreparedStatement.java:504)
> 	at com.example.SelectXaServlet.doGet(SelectXaServlet.java:41)
> {code}
> adapters/src/main/java/org/jboss/jca/adapters/jdbc/xa/XAManagedConnection.java
> {code}
>    public XAManagedConnection(XAManagedConnectionFactory mcf, XAConnection xaConnection, Properties props,
>                               int transactionIsolation, int psCacheSize) throws SQLException
>    {
>       super(mcf, xaConnection.getConnection(), props, transactionIsolation, psCacheSize);
>       this.xaConnection = xaConnection;
>       xaConnection.addConnectionEventListener(new javax.sql.ConnectionEventListener()
>       {
>          ...<snip>
>          public void connectionErrorOccurred(javax.sql.ConnectionEvent ce)
>          {
>             SQLException ex = ce.getSQLException();
>             broadcastConnectionError(ex);          // cleanup and return this connection when this event fired.
>          }
>       });
> {code}



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list