Uploaded image for project: 'IronJacamar'
  1. IronJacamar
  2. JBJCA-1347

NullPointerException in SemaphoreConcurrentLinkedDequeManagedConnectionPool.java:441

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • WildFly/IronJacamar 1.3.2.Final
    • None
    • None
    • Hide

      This can be tested by (assuming working Wildfly and PostgreSQL Server):
      1. Deploy PostgreSQL driver into the container
      2. Ccreating XA datasaource and pool with starting size zero, max size as appropriate, statistics-enabled should be set to true to see the NPE
      2. Test the database connection for Wildfly Admin interface (ensure ok)
      3. Stop PostgreSQL service
      4. Test the connection again (ensure fail)
      5. Start PostgreSQL service
      6. Test the connection again (ensure success)

      With PostgreSQL JDBC driver v 9.4.1208 Wildfly never recovers the connection (step 6) and must be restarted. With PostgreSQL JDBC driver v42.0.0 Wildfly reconnects with the next request

      Show
      This can be tested by (assuming working Wildfly and PostgreSQL Server): 1. Deploy PostgreSQL driver into the container 2. Ccreating XA datasaource and pool with starting size zero, max size as appropriate, statistics-enabled should be set to true to see the NPE 2. Test the database connection for Wildfly Admin interface (ensure ok) 3. Stop PostgreSQL service 4. Test the connection again (ensure fail) 5. Start PostgreSQL service 6. Test the connection again (ensure success) With PostgreSQL JDBC driver v 9.4.1208 Wildfly never recovers the connection (step 6) and must be restarted. With PostgreSQL JDBC driver v42.0.0 Wildfly reconnects with the next request

      Using a PostgreSQL XA datasource with statistics enabled we get a NullPointerException if the connection fails temporarily.

      With JDBC driver 9.4.1208 Wildfly never reconnects to the PostgreSQL server with the next request and Wildfly must be restarted. With JDBC driver 42.0.0 it does reconnect on next request.
      If statistics are disabled, the NPE does not occur and both drivers reconnect on the next request as expected.

      Specific location of NPE:
      https://github.com/ironjacamar/ironjacamar/blob/ironjacamar-1.3.2.Final/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/mcp/SemaphoreConcurrentLinkedDequeManagedConnectionPool.java#L441

      Note there is similar code on line 461 of the same class (in the exception handler)

      Example configuration follows
      With a PostgreSQL datasource configured in Wildfly as:

      <xa-datasource jndi-name="java:/DS.people" pool-name="DS.people" enabled="true" spy="true" statistics-enabled="true" use-java-context="true" use-ccm="true">
        <driver>postgresql</driver>
        <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
        <xa-datasource-property name="PortNumber">5432</xa-datasource-property>
        <xa-datasource-property name="DatabaseName">peopleviewstore</xa-datasource-property>
        <xa-datasource-property name="ApplicationName">people</xa-datasource-property>
        <xa-datasource-property name="assumeMinServerVersion">9.5</xa-datasource-property>
        <xa-datasource-property name="connectTimeout">10</xa-datasource-property>
        <xa-datasource-property name="currentSchema">public</xa-datasource-property>
        <xa-datasource-property name="hostRecheckSeconds">10</xa-datasource-property>
        <xa-datasource-property name="loginTimeout">10</xa-datasource-property>
        <xa-datasource-property name="logUnclosedConnections">true</xa-datasource-property>
        <xa-datasource-property name="socketTimeout">30</xa-datasource-property>
        <xa-datasource-property name="targetServerType">master</xa-datasource-property>
        <xa-datasource-property name="tcpKeepAlive">true</xa-datasource-property>
        <xa-pool>
          <min-pool-size>0</min-pool-size>
          <initial-pool-size>0</initial-pool-size>
          <max-pool-size>10</max-pool-size>
          <allow-multiple-users>false</allow-multiple-users>
        </xa-pool>
        <timeout>
          <xa-resource-timeout>0</xa-resource-timeout>
        </timeout>
        <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
        <statement>
          <track-statements>true</track-statements>
        </statement>
        <security>
          <user-name></user-name>
          <password></password>
        </security>
        <validation>
          <validate-on-match>true</validate-on-match>
          <use-fast-fail>true</use-fast-fail>
          <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter"/>
          <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker"/>
        </validation>
      </xa-datasource>
      

      And corresponding driver configuration:

      <driver name="postgresql" module="org.postgresql">
        <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
      </driver>
      

      we have deployed the JDBC driver as a module, module.xml looks like:

      <?xml version="1.0" ?>
      <module xmlns="urn:jboss:module:1.3" name="org.postgresql" slot="main">
        <resources>
          <resource-root path="postgresql-42.0.0.jar"/>
        </resources>
        <dependencies>
          <module name="javax.api"/>
          <module name="javax.transaction.api"/>
        </dependencies>
      </module>
      

              flaviarnn Flavia Rainone
              brett.dellegrazie_jira Brett Delle Grazie (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: