You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by "Hendy Irawan (JIRA)" <ji...@apache.org> on 2012/11/28 04:48:59 UTC

[jira] [Created] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Hendy Irawan created DIRAPI-97:
----------------------------------

             Summary: Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
                 Key: DIRAPI-97
                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
             Project: Directory Client API
          Issue Type: Bug
    Affects Versions: 1.0.0-M13
         Environment: Karaf
  Karaf version               2.3.0
  Karaf home                  /home/karaf/karaf
  Karaf base                  /home/karaf/karaf
  OSGi Framework              org.apache.felix.framework - 4.0.3

JVM
  Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
  Version                     1.7.0_09
  Vendor                      Oracle Corporation
  Uptime                      4 days 7 hours
  Total compile time          54.019 seconds
Threads
  Live threads                119
  Daemon threads              92
  Peak                        149
  Total started               3151
Memory
  Current heap size           63,365 kbytes
  Maximum heap size           506,816 kbytes
  Committed heap size         126,912 kbytes
  Pending objects             0
  Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
  Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
Classes
  Current classes loaded      13,396
  Total classes loaded        15,142
  Total classes unloaded      1,746
Operating system
  Name                        Linux version 3.6.5-linode47
  Architecture                i386
  Processors                  4

            Reporter: Hendy Irawan
            Priority: Critical


We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.

However, it seems that it's possible to break this and will cause :

{code}
Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
        at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
        ... 78 more
Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
ver, the connection is invalid
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
72)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
48)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
        at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
        ... 81 more
{code}

When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).

I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.

So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506178#comment-13506178 ] 

Hendy Irawan commented on DIRAPI-97:
------------------------------------

It probably is, but #DIRAPI-96 is fixed in M13 and I am using M13.
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506351#comment-13506351 ] 

Hendy Irawan commented on DIRAPI-97:
------------------------------------

Thank you [~elecharny] :-)

BTW, with the fix, is it necessary to call invalidateObject() explicitly? Or is my original code : simply borrowObject() then finally returnObject() should be sufficient ?
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505385#comment-13505385 ] 

Emmanuel Lecharny commented on DIRAPI-97:
-----------------------------------------

Is it possible that it's related to https://issues.apache.org/jira/browse/DIRAPI-96 ?
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505390#comment-13505390 ] 

Emmanuel Lecharny commented on DIRAPI-97:
-----------------------------------------

Can you give your code a try using this library : http://people.apache.org/~elecharny/shared-all-1.0.0-M13-SNAPSHOT.jar ?
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506179#comment-13506179 ] 

Hendy Irawan commented on DIRAPI-97:
------------------------------------

It's really hard to intentionally reproduce this bug. It could happen once over a course of a few days... :-(
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Hendy Irawan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13505208#comment-13505208 ] 

Hendy Irawan commented on DIRAPI-97:
------------------------------------

BTW this was how I did it :

{code}
	public static <V> V withConnection(@Nonnull final ObjectPool<LdapConnection> ldapPool, @Nonnull final Function<LdapConnection, V> function) {
		try {
			final LdapConnection conn = ldapPool.borrowObject();
			try {
				return function.apply(conn);
			} finally {
				ldapPool.returnObject(conn);
			}
		} catch (Exception e) {
			log.error("LDAP operation error", e);
			Throwables.propagate(e);
			return null;
		}
	}
{code}

That code can trigger this exception.

I am now trying another variant, will this work as expected?

{code}
public static <V> V withConnection(@Nonnull final ObjectPool<LdapConnection> ldapPool, @Nonnull final Function<LdapConnection, V> function) {
	final LdapConnection conn;
	try {
		conn = ldapPool.borrowObject();
	} catch (Exception e) {
		throw new RuntimeException("Cannot get LDAP connection", e);
	}
	try {
		V result = function.apply(conn);
		ldapPool.returnObject(conn);
		return result;
	} catch (Exception e) {
		try {
			ldapPool.invalidateObject(conn);
		} catch (Exception e1) {
			log.warn("Cannot invalidate LDAP connection after " + e + " exception", e1);
		}
		throw new RuntimeException("Cannot perform LDAP operation", e);
	}
}
{code}

If this error is by design, then some documentation should be provided on how to use LdapConnectionPool properly.
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (DIRAPI-97) Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid

Posted by "Emmanuel Lecharny (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DIRAPI-97?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13506327#comment-13506327 ] 

Emmanuel Lecharny commented on DIRAPI-97:
-----------------------------------------

DIRAPI-96 Is just marked as fixed, but is not in M13. M13 was released one month ago, and DIRAPI-96 has been fixed 2 weeks ago.

This is the reason I built a specific jar with the fix : it's a connection leak, leading to some error when trying to use the pool.

I suggest you use it, and if you get the error in the next few days (or weeks), update this JIRA.

We will probably conduct some load tests on our side to see if we can reproduce the issue at the same time.

Thanks anyway for the report !
                
> Unreliable LdapConnectionPool: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: DIRAPI-97
>                 URL: https://issues.apache.org/jira/browse/DIRAPI-97
>             Project: Directory Client API
>          Issue Type: Bug
>    Affects Versions: 1.0.0-M13
>         Environment: Karaf
>   Karaf version               2.3.0
>   Karaf home                  /home/karaf/karaf
>   Karaf base                  /home/karaf/karaf
>   OSGi Framework              org.apache.felix.framework - 4.0.3
> JVM
>   Java Virtual Machine        Java HotSpot(TM) Server VM version 23.5-b02
>   Version                     1.7.0_09
>   Vendor                      Oracle Corporation
>   Uptime                      4 days 7 hours
>   Total compile time          54.019 seconds
> Threads
>   Live threads                119
>   Daemon threads              92
>   Peak                        149
>   Total started               3151
> Memory
>   Current heap size           63,365 kbytes
>   Maximum heap size           506,816 kbytes
>   Committed heap size         126,912 kbytes
>   Pending objects             0
>   Garbage collector           Name = 'Copy', Collections = 970, Time = 6.659 seconds
>   Garbage collector           Name = 'MarkSweepCompact', Collections = 111, Time = 31.891 seconds
> Classes
>   Current classes loaded      13,396
>   Total classes loaded        15,142
>   Total classes unloaded      1,746
> Operating system
>   Name                        Linux version 3.6.5-linode47
>   Architecture                i386
>   Processors                  4
>            Reporter: Hendy Irawan
>            Priority: Critical
>
> We use LdapConnectionPool exclusively in order to increase performance without sacrificing stability.
> However, it seems that it's possible to break this and will cause :
> {code}
> Caused by: org.apache.directory.shared.ldap.model.exception.LdapException: org.apache.directory.ldap.client.api
> .exception.InvalidConnectionException: Cannot connect on the server, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3169)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3181)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3116)
>         at id.co.bippo.shop.LdapShopDao$1.apply(LdapShopDao.java:88)
>         ... 78 more
> Caused by: org.apache.directory.ldap.client.api.exception.InvalidConnectionException: Cannot connect on the ser
> ver, the connection is invalid
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.checkSession(LdapNetworkConnection.java:2
> 72)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.searchAsync(LdapNetworkConnection.java:15
> 48)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.search(LdapNetworkConnection.java:1586)
>         at org.apache.directory.ldap.client.api.LdapNetworkConnection.lookup(LdapNetworkConnection.java:3151)
>         ... 81 more
> {code}
> When it gets to this state, repeated calls to borrowObject/returnObject seem to return the same invalid connection(s).
> I can think of several reason why the connection was invalidated: LDAP connection breaks, LDAP server was restarted, but can be anything, really. However, I expect the pool would handle this, and purge invalid connections automatically.
> So that when ldapPool.borrowObject(); is called, the LdapConnection given should be valid & ready to use.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira