glassfish
  1. glassfish
  2. GLASSFISH-19190

Concurrent modification of HashMap in connection pool causes race condition

    Details

    • 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:
      None
    • 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

      Description

      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(HashMap.java:303)
              at com.sun.enterprise.resource.pool.monitor.ConnectionPoolEmitterImpl.getAppName(ConnectionPoolEmitterImpl.java:313)
              at com.sun.enterprise.resource.pool.monitor.ConnectionPoolEmitterImpl.connectionUsed(ConnectionPoolEmitterImpl.java:234)
              at com.sun.enterprise.resource.pool.PoolLifeCycleListenerRegistry.connectionUsed(PoolLifeCycleListenerRegistry.java:145)
              at com.sun.enterprise.resource.pool.ConnectionPool.internalGetResource(ConnectionPool.java:532)
              at com.sun.enterprise.resource.pool.ConnectionPool.getResource(ConnectionPool.java:381)
              at com.sun.enterprise.resource.pool.PoolManagerImpl.getResourceFromPool(PoolManagerImpl.java:242)
              at com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:167)
              at com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:338)
              at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:301)
              at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:190)
              at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:165)
              at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:160)
              at org.apache.jackrabbit.jca.JCARepositoryHandle.login(JCARepositoryHandle.java:75)
              at org.apache.jackrabbit.commons.AbstractRepository.login(AbstractRepository.java:123)
      -- Snip: the rest of the stacktrace due to company secret information
      

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

        Activity

        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 ]

          People

          • Assignee:
            dhaneesh.t.b
            Reporter:
            jaapcoomans
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: