You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrus Adamchik (JIRA)" <ji...@apache.org> on 2016/03/09 20:33:40 UTC

[jira] [Closed] (CAY-2067) Cayenne 4.0 connection pool is occasionally running out of connections

     [ https://issues.apache.org/jira/browse/CAY-2067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrus Adamchik closed CAY-2067.
--------------------------------
       Resolution: Fixed
    Fix Version/s: 4.0.M4

The problem wasn't what I thought. Still I think I found it. In UnmanagedPoolingDataSource.createUnchecked(..), a  semaphore controlling max pool size could get decremented before connection getting into the pool:

{noformat}
if (!poolCap.tryAcquire()) {
	return null;
}
PoolAwareConnection c = createWrapped();
pool.put(c, 1);
{noformat}

So I added try/catch for createWrapped, and the problem is fixed. This is confirmed by a unit test.

> Cayenne 4.0 connection pool is occasionally running out of connections
> ----------------------------------------------------------------------
>
>                 Key: CAY-2067
>                 URL: https://issues.apache.org/jira/browse/CAY-2067
>             Project: Cayenne
>          Issue Type: Bug
>    Affects Versions: 4.0.M3
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 4.0.M4
>
>
> Per this thread: http://mail-archives.apache.org/mod_mbox/cayenne-user/201603.mbox/%3CDC21E526-C64D-4438-97E3-0BF00C81CF03%40objectstyle.org%3E there is one or more scenarios when Cayenne new connection pool would run out of connections for no good reason. 
> One such scenario that may be the easiest to reproduce is when the DB is restarted, and all existing connections in the pool become invalid. The first thread requesting a new connection drains the pool of invalid connections (so the reported pool size is zero), but then fails to get a new connection. 
> While we are at it, we may need to add some logging and metrics to the pool.



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