Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeZc9-00017d-6o for pgsql-general@arkaria.postgresql.org; Thu, 25 Jan 2018 04:58:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eeZc8-0000lm-0p for pgsql-general@arkaria.postgresql.org; Thu, 25 Jan 2018 04:58:16 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eeZc7-0000lb-JT for pgsql-general@lists.postgresql.org; Thu, 25 Jan 2018 04:58:15 +0000 Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eeZc0-0007w5-B9 for pgsql-general@postgresql.org; Thu, 25 Jan 2018 04:58:14 +0000 Received: by mail-it0-x233.google.com with SMTP id m11so20451532iti.1 for ; Wed, 24 Jan 2018 20:58:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=u8mLaLaS3X3Ax2b/z65D9TiMArqHFwBMFnu3Rh15GLg=; b=lgkdYy1tK2hBHtcVtYmySBk7ThBmQwBDdrhuUtVtpnowdt363KpsfW5qC0lxomg4GU uh1VKXiVa3/a6dgMprw9ls7gvGo2/rMhqigV8VB5BOUyVkN0zlCTWpt/qr2Ti25nM9T7 vgEYvYsmNApFb2FsApGdjNEPL2oSORNTLH9om+8RB2XOIwJfFABlgn16TWiN6oX67Ekr HqAShVznNvDKEJlUwZXoIUhXoAsvyWOS7HlUzcmzWkuvYH23HhImpJwTTYllqUjaXvd1 sjN7run1WjNg/bf7jJ6dMcR6cgBcX4W+CTiqTtlMN6ffhjqnj/N+jJQSpgxgFVRg3LTf MglA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=u8mLaLaS3X3Ax2b/z65D9TiMArqHFwBMFnu3Rh15GLg=; b=nMoXYYugpK2e3EeFkxGPpuQJxGjmvVtiuBUWUG8EbVMPRHwy84s3m8GVqQrINywN5i FpIKuf4cM6uYdmgcXG0zW3eujnVroNaUZ5LewqXr6YPpz+dm2lWxmeM9G/NOvQvQjqBE o1TyscqIoS3gmkSpoO+KzMNvQaNndaTm1jR0UvQ6XNO1SFYtf0Dx1GTlrU7TG7BCiU7a ASS0LvrpeTQBjmfo3crdkkzcMflsKSsSGihy1VgSL4cDUyVwXEb2ArXp2BdINyD49gCt Fjtz3v652lQ0Fri5abXRiyRDumdiSp6hPIBjcOALI9WMU8Cg7lDGsRmPrtoGUElpl6OU qi9w== X-Gm-Message-State: AKwxyteDh832IHNVwWnRxeXfdliTH99XIOWBi+TXwixgzV/6oMoYBPBW 4+GSybfV+Rnc93II1bKrwh0= X-Google-Smtp-Source: AH8x224L30iDT9pWOQyMgC+ectPM6NR71tgnHZsgmXl4ZF8QQCkDW9uaH+S6IEfsCQM/469oG+0R5A== X-Received: by 10.36.65.202 with SMTP id b71mr10999291itd.56.1516856287309; Wed, 24 Jan 2018 20:58:07 -0800 (PST) Received: from ?IPv6:2601:681:5500:1e3c:64f5:c6fc:8942:baad? ([2601:681:5500:1e3c:64f5:c6fc:8942:baad]) by smtp.gmail.com with ESMTPSA id i201sm231990ita.14.2018.01.24.20.58.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Jan 2018 20:58:06 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: CannotAcquireResourceException in Junit From: Rob Sargent In-Reply-To: Date: Wed, 24 Jan 2018 21:58:05 -0700 Cc: "pgsql-general@postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: <75636663-BC9A-4DFD-BA21-3DCF16852A82@gmail.com> To: Abhra Kar X-Mailer: Apple Mail (2.3273) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk > On Jan 24, 2018, at 9:32 PM, Abhra Kar wrote: >=20 > Thanks Rob. >=20 > OS -- RHEL 6.7(Santiago) > Postgres Version -- 9.5 > Location --/usr/pgsql-9.5/bin/psql >=20 > Can you please guide me , how to stop all those connection = manually(=46rom psql prompt or linux shell or any .sh file with in = postgres directory) >=20 > Regards, > Abhra >=20 > On Thu, Jan 25, 2018 at 9:36 AM, Rob Sargent = wrote: >=20 > > On Jan 24, 2018, at 9:57 AM, Abhra Kar wrote: > > > > > > Hi, > > I am getting the following error while running bunch of = Junit test cases through =E2=80=9Cant test=E2=80=9D 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 =3D = entityManagerFactory.createEntityManager();//javax.persistence.EntityManag= er > > entityManager.getTransaction().begin(); > > } > > > > this method ran for all 300 test cases but didn=E2=80=99t 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 > > > Apparently Merlin is busy elsewhere. You need to name the OS, the = postgres version, and the stack you=E2=80=99re using. >=20 > But my guess is you=E2=80=99re not closing those connections and have = hit a configuration limit for maximum connection. >=20 >=20 >=20 Please don=E2=80=99t top post in the forum. Something like this from = https://stackoverflow.com/questions/5408156/how-to-drop-a-postgresql-datab= ase-if-there-are-active-connections-to-it You might want a bunch of=20 select pg_terminate_backend(); WARNING: this kills all connections.=20 SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname =3D 'TARGET_DB' AND pid <> pg_backend_pid();