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

PooledConnections don't initialize correctly when broker not available (causes problems with Failover)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 5.1.0
    • Transport
    • None
    • 5.1-SNAPSHOT

    Description

      In working with PooledConnections, I've found that there is a timing race condition that can occur on the initialization of new ConnectionPool objects. The ConnectionPool object adds a custom TransportListener, which implements the onException method, in order to be informed when the transport has failed, so that it can properly execute its 'expiredCheck' method, and allow the PooledConnectionFactory to remove it from the ConnectionPool....

      In the case of using an underlying FailoverTransport, which sets the maxReconnectAttempts to something small, such as "2", then it's possible that the FailoverTransport could fail prior to the ConnectionPool object completing it's own initialization, and thus prior to it's adding it's TransportListener to the connection. I would expect there are other transports that could also fail immediately and have the same behavior.

      This scenario is readily reproducible in the case where the client is started up with no broker available.

      I've found a solution by adding a simple check after the call to addTransportListener, to check for any prior transport failed, by calling 'connection.isTransportFailed()', and setting the 'hasFailed' flag if true. This will update the flag for those cases that did not successfully add the transport listener prior to that initial failure.

      Without this fix, the ConnectionPool is unusable, in that the underlying connection will never be evicted to from the PooledConnectionFactory....This is especially pronounced if the idleTimeout is set to 0, and it never recovers.

      Jason

      Attachments

        1. ConnectionPool.java
          8 kB
          Jason Rosenberg
        2. FailoverTransport.java
          27 kB
          Jason Rosenberg

        Activity

          People

            rajdavies Robert Davies
            jbrosenberg Jason Rosenberg
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: