Re: CannotAcquireResourceException in Junit - Mailing list pgsql-general

From Rob Sargent
Subject Re: CannotAcquireResourceException in Junit
Date
Msg-id A9339E2E-65B8-4ED8-93A8-9FD47DA2ED0E@gmail.com
Whole thread Raw
In response to Re: CannotAcquireResourceException in Junit  (Abhra Kar <abhra.kar@gmail.com>)
Responses Re: CannotAcquireResourceException in Junit
List 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
within 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
fromits 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
forall. 
> > 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();



pgsql-general by date:

Previous
From: Abhra Kar
Date:
Subject: Re: CannotAcquireResourceException in Junit
Next
From: Ian Harding
Date:
Subject: AFTER UPDATE trigger updating other records