5 Replies Latest reply on May 16, 2008 11:46 AM by Adrian Brock

    JBoss Connection Socket usage in error scenarios

    Dan Killey Newbie

      > JBoss 4.2.1.GA

      We have a HA datasource configured with both new-connection-sql and check-valid-connection-sql during a recent problem we noticed less than ideal behaviour, I was hoping someone with deeper knowledge could confirm there is nothing we can configure/control around this (and thus perhaps a bug?).

      Firstly our hypothesis, when a connection is successfully made to the DB but the subsequent new-connection-sql FAILS, the object is discarded before closing the socket. Thus the socket will remain open until the next GC.

      In our environment, 4k+ sockets can easily be accumilated under heavy load when the DB is down before GC's occur, thus depending on the systems file handle limit you can run out of file handles. Increasing the filehandles seems like cheating and the real solution would be to close the socket before discarding the object.


      So here is what we do know, why we are thinking the above:
      - Primary DB failed, secondary DB connection was switched to, life is good.
      - Sockets to the secondary DB were just fine, but the SQL level check (like select 1) failed, due a permissions issue. The application is not database critical, so functionality could of continued, however each user would go through this same process, each time a socket would be left open, eventually a starvation of file handles happened.


      Datasource file
      <?xml version="1.0" encoding="UTF-8"?>

      <ha-local-tx-datasource>
      <jndi-name>blahDS</jndi-name>
      <connection-url>database.url</connection-url>
      <url-delimiter>|</url-delimiter>
      <driver-class>database.driver[JTDS]</driver-class>
      <user-name>database.user</user-name>
      database.password
      <check-valid-connection-sql>SELECT * FROM MonitorTable</check-valid-connection-sql>
      <new-connection-sql>SELECT * FROM MonitorTable</new-connection-sql>
      <min-pool-size>20</min-pool-size>
      <max-pool-size>40</max-pool-size>
      <track-statements>warning</track-statements>
      <track-connection-by-tx>true</track-connection-by-tx>
      <statement-cache-size>20</statement-cache-size>
      <set-tx-query-timeout>true</set-tx-query-timeout>
      <query-timeout>30</query-timeout>
      <background-validation>true</background-validation>
      <background-validation-minutes>15</background-validation-minutes>
      <idle-timeout-minutes>13</idle-timeout-minutes>
      <blocking-timeout-millis>5000</blocking-timeout-millis>
      <use-fast-fail>true</use-fast-fail>
      <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
      </ha-local-tx-datasource>


      Any assistance would be appreciated, just let me know what other information may be appropriate.

      Thanks
      Dan