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

LDAPConnectionFactory is not closed when PersistentSearch is restarted



    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 13.5.0, 13.5.1, 14.0.0, 14.5.0, 14.5.1
    • 13.5.3, 6.0.0, 5.5.2
    • idrepo, sms
    • AM Sustaining Sprint 50
    • 5
    • No
    • Yes
    • No
    • Yes and I used the same an in the 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


      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.


          Issue Links



              sachiko Sachiko Wallace
              sachiko Sachiko Wallace
              0 Vote for this issue
              6 Start watching this issue