Context.close does not close ldap connections in sun ldap spi

Discussions

General J2EE: Context.close does not close ldap connections in sun ldap spi

  1. Using Tomcat 5.0.24 and jdk 1.4.1.0.2 to run jetspeed portal container and CAS (yale university) as a central authentication service.

    I am seeing the following behaviour. I am using the ldap/JNDI connection pool SPI by sun for connecting and accessing a LDAP data source. It seems as if the connections created are sticky. They continue to be busy even after they are released. Given below is a sample test unit run that shows this problem.

    I am using the ldap data source to authenticate users in my application. Each time the user logs an ldap connection is created and user info. retrieved. This info. is then cached in a security cache for further reference. I have set uop the max connection as 25, but I have seen that if i continue to create and release connections in a sequence over a period of time the max connection limit is reached and the next request for a connection times out. If I do a System.gc() immedeately after the (instance of InitialDirContext)ctx.close(); call everything seems fine, as the connections keep getting garbage collected. Shouldn't the close() call free up all the connection resources and make the connection available for serving new requests rather than waiting for a GC to take place , though this doesn't seem to happen.. Does any one have any inputs on this.

    If the connection is not available till GC takes place then do you have any metrics that can be used for setting up max connection figures in such a scenario.

    LdapPoolManager: using authmech: simple
    com.sun.jndi.ldap.pool.Pool@15a3d6b{ushqdeng69.corpnet.corio.com:389:::cn=Directory Manager=com.sun.jndi.ldap.pool.ConnectionsRef@d70d7a}.get(): ushqdeng69.corpnet.corio.com:389:::cn=Directory Manager
    com.sun.jndi.ldap.pool.Pool@15a3d6b{ushqdeng69.corpnet.corio.com:389:::cn=Directory Manager=com.sun.jndi.ldap.pool.ConnectionsRef@d70d7a}.size: 1
    com.sun.jndi.ldap.pool.Pool@15a3d6b{ushqdeng69.corpnet.corio.com:389:::cn=Directory Manager=com.sun.jndi.ldap.pool.ConnectionsRef@d70d7a}.get(): size after: 1
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.get(): before; size: 25
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b5f53a busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b1b4c3 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@27391d busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@1db4f6f busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@14c1103 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@1592174 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@a352a5 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@18f6235 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@115273a busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@12d263f busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@3570b0 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@a17083 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@16fe0f4 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b0ce8f busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@4b035d busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@a761fe busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@7bb290 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b02efa busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@4e280c busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@f01a1e busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@1342ba4 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@11e1e67 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@18d9850 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@10ab323 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@176e552 busy
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.get(): waiting; size: 25
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b5f53a busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b1b4c3 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@27391d busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@1db4f6f busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@14c1103 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@1592174 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@a352a5 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@18f6235 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@115273a busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@12d263f busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@3570b0 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@a17083 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@16fe0f4 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b0ce8f busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@4b035d busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@a761fe busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@7bb290 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@b02efa busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@4e280c busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@f01a1e busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@1342ba4 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@11e1e67 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@18d9850 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@10ab323 busy
    ConnectionDesc.tryUse() com.sun.jndi.ldap.LdapClient@176e552 busy
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): com.sun.jndi.ldap.LdapClient@18d9850; size: 25
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): closing com.sun.jndi.ldap.LdapClient@18d9850; size: 25
    Close com.sun.jndi.ldap.LdapClient@18d9850
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): notify; size: 24
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): com.sun.jndi.ldap.LdapClient@10ab323; size: 24
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): closing com.sun.jndi.ldap.LdapClient@10ab323; size: 24
    Close com.sun.jndi.ldap.LdapClient@10ab323
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): notify; size: 23
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): com.sun.jndi.ldap.LdapClient@176e552; size: 23
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): closing com.sun.jndi.ldap.LdapClient@176e552; size: 23
    Close com.sun.jndi.ldap.LdapClient@176e552
    com.sun.jndi.ldap.pool.Connections@1ef9f1d.release(): notify; size: 22
    javax.naming.CommunicationException: Timeout exceeded while waiting for a connection: 40000ms
    at com.sun.jndi.ldap.pool.Connections.get(Connections.java:128)
    at com.sun.jndi.ldap.pool.Pool.getPooledConnection(Pool.java:85)
    at com.sun.jndi.ldap.LdapPoolManager.getLdapClient(LdapPoolManager.java:291)
    at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1662)
    at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2528)
    at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:275)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:173)
    at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:191)
    at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
    at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:662)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
    at javax.naming.InitialContext.init(InitialContext.java:219)
    at javax.naming.InitialContext.<init>(InitialContext.java:195)
    at javax.naming.directory.InitialDirContext.<init>(InitialDirContext.java:80)
    at com.corio.uaaa.dao.ldap.LdapContextPool.getContext(LdapContextPool.java:235)

    any kind of inputs would be really helpful.

    Threaded Messages (1)

  2. A bug fixed.[ Go to top ]

    This is a bug in Sun's JDk which I think got fixed in a latest rel.