Re: LdapConnectionPool.getConnection doing extraneous search?

2021-03-21 Thread Emmanuel Lécharny




On 21/03/2021 13:43, Shawn McKinney wrote:



On Mar 20, 2021, at 10:40 PM, Emmanuel Lécharny  wrote:

I guess that the very first time we create the connection, when asking for one 
from a pool, we test it beforehandd, and this is done with the less costly 
operation: a dummy search.

This is due to commons-pool logic where you can ask the pool to validate the 
connection one way or the other. We are probably using 
LookupLdapConnectionValidator for that purpose:


Hi Emmanuel,

It’s actually sending that dummy search every time, which of course isn’t good. 
 Here’s the code to create the pool:

```
// Create the Admin pool
adminPool = new LdapConnectionPool( poolFactory );
adminPool.setTestOnBorrow( true );
adminPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
adminPool.setMaxActive( max );
adminPool.setMinIdle( min );
adminPool.setMaxIdle( -1 );
adminPool.setTestWhileIdle( testWhileIdle );
adminPool.setTimeBetweenEvictionRunsMillis( timeBetweenEvictionRunMillis );
```

Notice that ‘setTestOnBorrow' being set to true.


Yes, I forgot to mention it. This is configurable.




When I flip that switch, the dummy search no longer occurs when connection is 
retrieved, which is `good.

Wonder what we lose.  Recovery from connections being timed out by server or 
reset by intermediaries like routers?


Not that much. The gain is not enormous either, just  a round trip. The 
LDAP server is not under heavy strain with such a request, it's an 
automatic answer. This is what you would use for a Health Check.


The risk not doing such a check is very very tenuous.

However, we have implemented it as commons-pool requires it to be 
implemented. The question would be to know if we should make it a default.


-
To unsubscribe, e-mail: api-unsubscr...@directory.apache.org
For additional commands, e-mail: api-h...@directory.apache.org



Re: LdapConnectionPool.getConnection doing extraneous search?

2021-03-21 Thread Shawn McKinney


> On Mar 20, 2021, at 10:40 PM, Emmanuel Lécharny  wrote:
> 
> I guess that the very first time we create the connection, when asking for 
> one from a pool, we test it beforehandd, and this is done with the less 
> costly operation: a dummy search.
> 
> This is due to commons-pool logic where you can ask the pool to validate the 
> connection one way or the other. We are probably using 
> LookupLdapConnectionValidator for that purpose:

Hi Emmanuel,

It’s actually sending that dummy search every time, which of course isn’t good. 
 Here’s the code to create the pool:

```
// Create the Admin pool
adminPool = new LdapConnectionPool( poolFactory );
adminPool.setTestOnBorrow( true );
adminPool.setWhenExhaustedAction( GenericObjectPool.WHEN_EXHAUSTED_GROW );
adminPool.setMaxActive( max );
adminPool.setMinIdle( min );
adminPool.setMaxIdle( -1 );
adminPool.setTestWhileIdle( testWhileIdle );
adminPool.setTimeBetweenEvictionRunsMillis( timeBetweenEvictionRunMillis );
```

Notice that ‘setTestOnBorrow' being set to true.

When I flip that switch, the dummy search no longer occurs when connection is 
retrieved, which is `good.

Wonder what we lose.  Recovery from connections being timed out by server or 
reset by intermediaries like routers?  

Must do more testing…

—
Shawn
-
To unsubscribe, e-mail: api-unsubscr...@directory.apache.org
For additional commands, e-mail: api-h...@directory.apache.org