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_b14
    • Fix Version/s: 4.1_b07
    • 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

          People

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

            Dates

            • Created:
              Updated:
              Resolved: