pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
CannotAcquireResourceException in Junit
6+ messages / 3 participants
[nested] [flat]

* CannotAcquireResourceException in Junit
@ 2018-01-24 16:57 Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:06 ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Abhra Kar @ 2018-01-24 16:57 UTC (permalink / raw)
  To: pgsql-general

Hi,

         I am getting the following error while running bunch of Junit test
cases through “ant test” command----

 Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A
ResourcePool could not acquire a resource from its primary factory or
source.

PFA full stack trace.



After execution of 300 test cases I got this error. The setup() method code
snippet is ---


@Before

    public void setUp() throws Exception {

        entityManager =
entityManagerFactory.createEntityManager();//javax.persistence.EntityManager

        entityManager.getTransaction().begin();

}


this method ran for all 300 test cases but didn’t get error .



Another 900 test cases are remaining. I tried running single test cases
from those test cases, getting same error for all.

What is root cause of this error.


Thanks and Regards,

Abhra

Attachments:

  StackTrace.doc (application/msword, 205.0K) download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: CannotAcquireResourceException in Junit
  2018-01-24 16:57 CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
@ 2018-01-25 04:06 ` Rob Sargent <robjsargent@gmail.com>
  2018-01-25 04:32   ` Re: CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Rob Sargent @ 2018-01-25 04:06 UTC (permalink / raw)
  To: Abhra Kar <abhra.kar@gmail.com>; +Cc: pgsql-general


> On Jan 24, 2018, at 9:57 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
> 
>  
> Hi,
>          I am getting the following error while running bunch of Junit test cases through “ant test” command----
>  Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source. 
> PFA full stack trace.
>  
> After execution of 300 test cases I got this error. The setup() method code snippet is ---
> 
> @Before
>     public void setUp() throws Exception {     
>         entityManager = entityManagerFactory.createEntityManager();//javax.persistence.EntityManager
>         entityManager.getTransaction().begin();
> }
> 
> this method ran for all 300 test cases but didn’t get error .
>  
> Another 900 test cases are remaining. I tried running single test cases from those test cases, getting same error for all.
> What is root cause of this error.
> 
> Thanks and Regards,
> Abhra
> <StackTrace.doc>
Apparently Merlin is busy elsewhere.  You need to name the OS, the postgres version, and the stack you’re using.

But my guess is you’re not closing those connections and have hit a configuration limit for maximum connection.






^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: CannotAcquireResourceException in Junit
  2018-01-24 16:57 CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:06 ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
@ 2018-01-25 04:32   ` Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:58     ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Abhra Kar @ 2018-01-25 04:32 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general

Thanks Rob.


OS -- RHEL 6.7(Santiago)

Postgres Version -- 9.5

Location --*/usr/pgsql-9.5/bin/psql*


Can you please guide me , how to stop all those connection manually(From
psql prompt or linux shell or any .sh file with in postgres directory)


Regards,

Abhra

On Thu, Jan 25, 2018 at 9:36 AM, Rob Sargent <robjsargent@gmail.com> wrote:

>
> > On Jan 24, 2018, at 9:57 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
> >
> >
> > Hi,
> >          I am getting the following error while running bunch of Junit
> test cases through “ant test” command----
> >  Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException:
> A ResourcePool could not acquire a resource from its primary factory or
> source.
> > PFA full stack trace.
> >
> > After execution of 300 test cases I got this error. The setup() method
> code snippet is ---
> >
> > @Before
> >     public void setUp() throws Exception {
> >         entityManager = entityManagerFactory.
> createEntityManager();//javax.persistence.EntityManager
> >         entityManager.getTransaction().begin();
> > }
> >
> > this method ran for all 300 test cases but didn’t get error .
> >
> > Another 900 test cases are remaining. I tried running single test cases
> from those test cases, getting same error for all.
> > What is root cause of this error.
> >
> > Thanks and Regards,
> > Abhra
> > <StackTrace.doc>
> Apparently Merlin is busy elsewhere.  You need to name the OS, the
> postgres version, and the stack you’re using.
>
> But my guess is you’re not closing those connections and have hit a
> configuration limit for maximum connection.
>
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: CannotAcquireResourceException in Junit
  2018-01-24 16:57 CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:06 ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
  2018-01-25 04:32   ` Re: CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
@ 2018-01-25 04:58     ` Rob Sargent <robjsargent@gmail.com>
  2018-01-30 10:11       ` Re: CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Rob Sargent @ 2018-01-25 04:58 UTC (permalink / raw)
  To: Abhra Kar <abhra.kar@gmail.com>; +Cc: pgsql-general


> On Jan 24, 2018, at 9:32 PM, Abhra Kar <abhra.kar@gmail.com> wrote:
> 
> Thanks Rob.
> 
> OS -- RHEL 6.7(Santiago)
> Postgres Version -- 9.5
> Location --/usr/pgsql-9.5/bin/psql
> 
> Can you please guide me , how to stop all those connection manually(From psql prompt or linux shell or any .sh file with in postgres directory)
> 
> Regards,
> Abhra
> 
> On Thu, Jan 25, 2018 at 9:36 AM, Rob Sargent <robjsargent@gmail.com> wrote:
> 
> > On Jan 24, 2018, at 9:57 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
> >
> >
> > Hi,
> >          I am getting the following error while running bunch of Junit test cases through “ant test” command----
> >  Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
> > PFA full stack trace.
> >
> > After execution of 300 test cases I got this error. The setup() method code snippet is ---
> >
> > @Before
> >     public void setUp() throws Exception {
> >         entityManager = entityManagerFactory.createEntityManager();//javax.persistence.EntityManager
> >         entityManager.getTransaction().begin();
> > }
> >
> > this method ran for all 300 test cases but didn’t get error .
> >
> > Another 900 test cases are remaining. I tried running single test cases from those test cases, getting same error for all.
> > What is root cause of this error.
> >
> > Thanks and Regards,
> > Abhra
> > <StackTrace.doc>
> Apparently Merlin is busy elsewhere.  You need to name the OS, the postgres version, and the stack you’re using.
> 
> But my guess is you’re not closing those connections and have hit a configuration limit for maximum connection.
> 
> 
> 
Please don’t top post in the forum.

Something like this from https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-database-if-there-are-active-co...

 You might want a bunch of 
select pg_terminate_backend(<pick one pid you no is yours from ps output>);


WARNING: this kills all connections. 
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM
 pg_stat_activity
WHERE pg_stat_activity.datname = 'TARGET_DB'
AND pid <> pg_backend_pid();





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: CannotAcquireResourceException in Junit
  2018-01-24 16:57 CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:06 ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
  2018-01-25 04:32   ` Re: CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:58     ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
@ 2018-01-30 10:11       ` Abhra Kar <abhra.kar@gmail.com>
  2018-01-30 11:52         ` Re: CannotAcquireResourceException in Junit rob stone <floriparob@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Abhra Kar @ 2018-01-30 10:11 UTC (permalink / raw)
  To: Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general

Hi,
       Sorry for late reply. Below options I tried ---
1>pg_terminate_backend --> Successful execution.
2> Increase max_connection to 900 in
/var/lib/pgsql/9.5/data/postgresql.conf .After modify restart psql
service---

service postgresql-9.5 start

service postgresql-9.5 stop


Then execute select * from pg_stat_activity it shows 2 connections.



3>set cp3p0 options ----
com.mchange.v2.c3p0.ComboPooledDataSource cpds = new
ComboPooledDataSource();
  cpds.setMaxPoolSize(1000);
            cpds.setMaxStatements(0);
            cpds.setInitialPoolSize(50);
            cpds.setAcquireIncrement(5);
            cpds.setAcquireRetryAttempts(5);


But the problem still persist.Please provide suggestion.

Regards,
Abhra

On Thu, Jan 25, 2018 at 10:28 AM, Rob Sargent <robjsargent@gmail.com> wrote:

>
> > On Jan 24, 2018, at 9:32 PM, Abhra Kar <abhra.kar@gmail.com> wrote:
> >
> > Thanks Rob.
> >
> > OS -- RHEL 6.7(Santiago)
> > Postgres Version -- 9.5
> > Location --/usr/pgsql-9.5/bin/psql
> >
> > Can you please guide me , how to stop all those connection manually(From
> psql prompt or linux shell or any .sh file with in postgres directory)
> >
> > Regards,
> > Abhra
> >
> > On Thu, Jan 25, 2018 at 9:36 AM, Rob Sargent <robjsargent@gmail.com>
> wrote:
> >
> > > On Jan 24, 2018, at 9:57 AM, Abhra Kar <abhra.kar@gmail.com> wrote:
> > >
> > >
> > > Hi,
> > >          I am getting the following error while running bunch of Junit
> test cases through “ant test” command----
> > >  Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException:
> A ResourcePool could not acquire a resource from its primary factory or
> source.
> > > PFA full stack trace.
> > >
> > > After execution of 300 test cases I got this error. The setup() method
> code snippet is ---
> > >
> > > @Before
> > >     public void setUp() throws Exception {
> > >         entityManager = entityManagerFactory.
> createEntityManager();//javax.persistence.EntityManager
> > >         entityManager.getTransaction().begin();
> > > }
> > >
> > > this method ran for all 300 test cases but didn’t get error .
> > >
> > > Another 900 test cases are remaining. I tried running single test
> cases from those test cases, getting same error for all.
> > > What is root cause of this error.
> > >
> > > Thanks and Regards,
> > > Abhra
> > > <StackTrace.doc>
> > Apparently Merlin is busy elsewhere.  You need to name the OS, the
> postgres version, and the stack you’re using.
> >
> > But my guess is you’re not closing those connections and have hit a
> configuration limit for maximum connection.
> >
> >
> >
> Please don’t top post in the forum.
>
> Something like this from https://stackoverflow.com/
> questions/5408156/how-to-drop-a-postgresql-database-if-
> there-are-active-connections-to-it
>
>  You might want a bunch of
> select pg_terminate_backend(<pick one pid you no is yours from ps output>);
>
>
> WARNING: this kills all connections.
> SELECT pg_terminate_backend(pg_stat_activity.pid)
> FROM
>  pg_stat_activity
> WHERE pg_stat_activity.datname = 'TARGET_DB'
> AND pid <> pg_backend_pid();
>
>

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: CannotAcquireResourceException in Junit
  2018-01-24 16:57 CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:06 ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
  2018-01-25 04:32   ` Re: CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
  2018-01-25 04:58     ` Re: CannotAcquireResourceException in Junit Rob Sargent <robjsargent@gmail.com>
  2018-01-30 10:11       ` Re: CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
@ 2018-01-30 11:52         ` rob stone <floriparob@gmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: rob stone @ 2018-01-30 11:52 UTC (permalink / raw)
  To: Abhra Kar <abhra.kar@gmail.com>; Rob Sargent <robjsargent@gmail.com>; +Cc: pgsql-general



On Tue, 2018-01-30 at 15:41 +0530, Abhra Kar wrote:
> Hi,
>        Sorry for late reply. Below options I tried --- 
> 1>pg_terminate_backend --> Successful execution.
> 2> Increase max_connection to 900 in
> /var/lib/pgsql/9.5/data/postgresql.conf .After modify restart psql
> service--- 
> service postgresql-9.5 start
> service postgresql-9.5 stop
> 
> Then execute select * from pg_stat_activity it shows 2 connections.
> 
> 
> 3>set cp3p0 options ----           
> com.mchange.v2.c3p0.ComboPooledDataSource cpds = new
> ComboPooledDataSource();
>   cpds.setMaxPoolSize(1000);
>             cpds.setMaxStatements(0);
>             cpds.setInitialPoolSize(50);
>             cpds.setAcquireIncrement(5);
>             cpds.setAcquireRetryAttempts(5);
> 
> 
> But the problem still persist.Please provide suggestion.
> 
> Regards,
> Abhra
> 



The stack trace you sent with your original post shows hibernate
crashing as it has no connection string.
You are using hibernate as the go between the RDBMS and your app.
The problem is more than likely in your c3p0 package.
I haven't a clue what it is supposed to do, but my guess is that the
faulty code is there, not with your configuration parameters.

My 0.02 worth.
HTH,
Rob




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2018-01-30 11:52 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-24 16:57 CannotAcquireResourceException in Junit Abhra Kar <abhra.kar@gmail.com>
2018-01-25 04:06 ` Rob Sargent <robjsargent@gmail.com>
2018-01-25 04:32   ` Abhra Kar <abhra.kar@gmail.com>
2018-01-25 04:58     ` Rob Sargent <robjsargent@gmail.com>
2018-01-30 10:11       ` Abhra Kar <abhra.kar@gmail.com>
2018-01-30 11:52         ` rob stone <floriparob@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox