Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-3506

Access to ConnectionPool.createSession needs to be synchronized

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.5.0
    • 5.6.0
    • Broker
    • activemq-pool, PooledConnectionFactory with maximumActive=1 and blockIfSessionPoolIsFull=true (default behavior)

    • Patch Available

    Description

      When configuring a PooledConnectionFactory with maximumActive=1 and blockIfSessionPoolIsFull=true (default behavior for latter config) it is possible that multiple threads that concurrently try to use the same JMS connection to create a new session might create more sessions than the configured maximumActive limit.

      That's because the call to ConnectionPool.createSession() is not synchronized and if multiple threads try to call this method concurrently (on the same underlying JMS connection) then the if-condition in

      SessionKey key = new SessionKey(transacted, ackMode);
      SessionPool pool = cache.get(key);
      if (pool == null) {
        pool = createSessionPool(key);
        cache.put(key, pool);
      }
      

      will evaluate to true for all threads and they all end up creating their own sessionPool using the same SessionKey properties.
      Access to the if-condition needs to be synchronized so that only one session pool gets created. That will ensure that not more than the configured maximumActive number of sessions can get created.

      Attachments

        1. AMQ-3506.patch
          6 kB
          Torsten Mielke

        Activity

          People

            Unassigned Unassigned
            tmielke Torsten Mielke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 3h
                3h
                Remaining:
                Remaining Estimate - 3h
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified