[ 
https://issues.apache.org/jira/browse/TINKERPOP-1351?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15357888#comment-15357888
 ] 

stephen mallette commented on TINKERPOP-1351:
---------------------------------------------

I'm going to add your change on the TINKERPOP-1352 branch so that we can have 
one pull request to represent all these bug fixes related to the connection 
pool.  It would be great if you could test that branch out if you get a chance. 
You can see the PR here:

https://github.com/apache/tinkerpop/pull/352

Running tests over these changes now and should be pushing shortly.

> Number of connections going beyond the pool max size
> ----------------------------------------------------
>
>                 Key: TINKERPOP-1351
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1351
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: driver
>    Affects Versions: 3.1.2-incubating
>         Environment: RESTful web service using gremlin driver to send request 
> to a Gremlin Server
>            Reporter: Ramzi Oueslati
>            Assignee: stephen mallette
>             Fix For: 3.1.3, 3.2.1
>
>
> When the gremlin driver is used with an important number of concurrent 
> requests, sockets are opened far beyond the max pool size.
> At some point, the connections are destroyed, the pool is empty and then the 
> borrowConnection process goes through :
> {code:java}
>         if (connections.isEmpty()) {
>             logger.debug("Tried to borrow connection but the pool was empty 
> for {} - scheduling pool creation and waiting for connection", host);
>             for (int i = 0; i < minPoolSize; i++) {
>                 scheduledForCreation.incrementAndGet();
>                 newConnection();
>             }
>             return waitForConnection(timeout, unit);
>         }
> {code}
> If many connections are borrowed at the same time then this code will 
> schedule as many connections for creation.
> I added a check :
> {code:java}
>             for (int i = 0; i < minPoolSize; i++) {
>                 if (scheduledForCreation.get() < minPoolSize) {
>                     scheduledForCreation.incrementAndGet();
>                     logger.debug("borrowConnection: [inc] 
> scheduledForCreation=" + scheduledForCreation.get());
>                     newConnection();
>                 }
>             }
> {code}
> It seems to solve the problem.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to