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"?>

      <check-valid-connection-sql>SELECT * FROM MonitorTable</check-valid-connection-sql>
      <new-connection-sql>SELECT * FROM MonitorTable</new-connection-sql>

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