1. glassfish
  2. GLASSFISH-19190

Concurrent modification of HashMap in connection pool causes race condition


    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.1.2_dev
    • Fix Version/s: 4.1_dev
    • Component/s: jca
    • Labels:
    • Environment:

      OS: Red Hat Enterprise Linux Server release 5.8 (Tikanga)
      CPU: 4 x Intel(R) Xeon(R) CPU X5670 @ 2.93GHz
      RAM: 8174464 kB
      JRE: 1.6.0_31-b04


      My company is running an application on GlassFish that uses a JackRabbit JCR Repository via a JCA connector.

      Every once in a while a thread falls in some kind of livelock while obtaining a JCR connection from the connection pool.
      It starts out with one thread, but spreads out to more threads within a hour until all CPU's are fully occupied and the system becomes too slow to operate.

      Obtained the following stacktrace via jstack:

      "p: thread-pool-1; w: 251" daemon prio=10 tid=0x00002aaaba11e000 nid=0x940 runnable [0x0000000043e3a000]
         java.lang.Thread.State: RUNNABLE
              at java.util.HashMap.get(
              at com.sun.enterprise.resource.pool.monitor.ConnectionPoolEmitterImpl.getAppName(
              at com.sun.enterprise.resource.pool.monitor.ConnectionPoolEmitterImpl.connectionUsed(
              at com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry.connectionUsed(
              at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(
              at com.sun.enterprise.resource.pool.ConnectionPool.getResource(
              at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(
              at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(
              at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(
              at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(
              at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(
              at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(
              at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(
              at org.apache.jackrabbit.jca.JCARepositoryHandle.login(
              at org.apache.jackrabbit.commons.AbstractRepository.login(
      -- Snip: the rest of the stacktrace due to company secret information

      It seems that the resourceAppAssociationMap in ConnectionPoolEmitterImpl should actually be a ConcurrentHashMap.


        jaapcoomans created issue -
        shreedhar_ganapathy made changes -
        Field Original Value New Value
        Assignee shreedhar_ganapathy [ shreedhar_ganapathy ] Sivakumar Thyagarajan [ sivakumart ]
        Component/s jca [ 10602 ]
        Sivakumar Thyagarajan made changes -
        Assignee Sivakumar Thyagarajan [ sivakumart ] Jagadish [ jr158900 ]
        Jagadish made changes -
        Tags connectionpool connectors connectionpool connectors 4_0_1-review
        alan42 made changes -
        Tags connectionpool connectors 4_0_1-review 4_0_1-approved 4_0_1-review connectionpool connectors
        alan42 made changes -
        Tags 4_0_1-approved 4_0_1-review connectionpool connectors 4_0_1-approved connectionpool connectors
        dhaneesh.t.b made changes -
        Assignee Jagadish [ jr158900 ] dhaneesh.t.b [ dhaneesh.t.b ]
        dhaneesh.t.b made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 4.0.1_b07 [ 16925 ]
        Resolution Fixed [ 1 ]
        Joe Di Pol made changes -
        Affects Version/s 3.1.2_dev [ 17782 ]
        Joe Di Pol made changes -
        Fix Version/s 4.1_dev [ 17785 ]


          • Assignee:
          • Votes:
            0 Vote for this issue
            1 Start watching this issue


            • Created: