Uploaded image for project: 'OpenAM'
  1. OpenAM
  2. OPENAM-12920

LDAPConnectionFactory is not closed when PersistentSearch is restarted

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 13.5.0, 13.5.1, 14.0.0, 14.5.0, 14.5.1
    • Fix Version/s: 13.5.3, 6.0.0, 5.5.2
    • Component/s: idrepo, sms
    • Labels:
    • Sprint:
      AM Sustaining Sprint 50
    • Story Points:
      5
    • Needs backport:
      No
    • Support Ticket IDs:
    • Needs QA verification:
      Yes
    • Functional tests:
      No
    • Are the reproduction steps defined?:
      Yes and I used the same an in the description

      Description

      Bug description

      LDAPConnectionFactory is not closed when PersistentSearch is restarted, leaving large number of LDAP connections

      How to reproduce the issue

      1. install 13.5.1 or above with OPENAM-10852 fix
      2. login to admin console with amadmin (to make sure IdRepo is initialized and cached)
      3. stop external user datastore
      4. start external user datastore
      5. notice "addListener invoked" is printed in IdRepo, but not "removelistener invoked"
      6. run jmap command to get heapdump
        jmap -dump:format=b,file=heap-001.bin <pid>
        
      7. run jhat and check the number of LDAPConnectionFactory with JQuery
        select {
                objectid: objectid(s),
                isClosed: s.isClosed? s.isClosed.toString() : "null",
        		factory: s.factory? s.factory : "null"}
            from instanceof org.forgerock.opendj.ldap.CachedConnectionPool s
        
      8. repeat stop/start external user datastore and notice the number of CachedConnectionPool/LDAPConnectionFactory class instances slowly increase.

      Also, you will eventually see exceptions such as :

      DJLDAPv3Repo:04/11/2018 05:44:11:748 PM CDT: Thread[http-nio-8080-exec-8,5,main]: TransactionId[e2f76615-ee4e-42a6-8241-6f129432ff2d-56036]
      An error occurred while trying to authenticate a user: org.forgerock.opendj.ldap.ConnectionException: Connect Error: No operational connection factories available
      
      Expected behaviour

      CachedConnectionPool/LDAPConnectionFactory should be closed properly

      Current behaviour

      The number of CachedConnectionPool/LDAPConnectionFactory class instances slowly increase until the exceptions start showing.

      Work around

      N/A

      Code analysis

      OPENAM-10852 has removed IdRepo.removeListener which called LDAPv3PersistentSearch.stopSearch() which closed LDAPConnectionFactory.
      I think OPENAM-10852 can be fixed by just skipping IdRepo.shutdown call.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                sachiko Sachiko Wallace
                Reporter:
                sachiko Sachiko Wallace
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: