Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 12725 invoked from network); 16 Feb 2005 17:33:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Feb 2005 17:33:49 -0000 Received: (qmail 26387 invoked by uid 500); 16 Feb 2005 17:33:47 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 26350 invoked by uid 500); 16 Feb 2005 17:33:47 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 26336 invoked by uid 99); 16 Feb 2005 17:33:47 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: neutral (hermes.apache.org: local policy) Received: from gw02.mail.saunalahti.fi (HELO gw02.mail.saunalahti.fi) (195.197.172.116) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 16 Feb 2005 09:33:46 -0800 Received: from proxyplus.universe (GYMKDCCXLVIII.dsl.saunalahti.fi [85.77.27.249]) by gw02.mail.saunalahti.fi (Postfix) with ESMTP id 052ADB8E8F for ; Wed, 16 Feb 2005 19:33:42 +0200 (EET) Received: from 192.168.0.103 [192.168.0.103] by Proxy+; Wed, 16 Feb 2005 19:22:24 +0200 for Message-ID: <42138167.9060803@surfeu.fi> Date: Wed, 16 Feb 2005 19:22:47 +0200 From: Ilkka Priha User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.5) Gecko/20041217 X-Accept-Language: fi, en, en-us MIME-Version: 1.0 To: OJB Developers List Subject: Closed connections in pool Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hello We noticed that under heavy load (lack of memory) OJB returns closed Connections into the pool. This happens when the finalizer activates the finalize method of PersistenceBroker instances. At least MySQL Connections are already closed at this point (their finalize called as well?). Closed Connections cause a lot of trouble later on when borrowed back to use from the pool. System Thread [Finalizer] (Suspended (breakpoint at line 61 in ConnectionFactoryPooledImpl)) ConnectionFactoryPooledImpl.returnConnectionToPool(JdbcConnectionDescriptor, Connection) line: 61 ConnectionFactoryPooledImpl(ConnectionFactoryAbstractImpl).releaseConnection( JdbcConnectionDescriptor, Connection) line: 90 ConnectionManagerImpl.releaseConnection() line: 314 PersistenceBrokerImpl.close() line: 336 PersistenceBrokerImpl.finalize() line: 1946 Finalizer.invokeFinalizeMethod(Object) line: not available [native method] Finalizer.runFinalizer() line: 83 Finalizer.access$100(Finalizer) line: 14 Finalizer$FinalizerThread.run() line: 160 We added a simple check to an extended version of the ConnectionFactoryPooledImpl, which fixes the problem and could be applied to the original version, too. -- Ilkka public void returnConnectionToPool(JdbcConnectionDescriptor jcd, Connection con) throws LookupException { try { if (!con.isClosed()) { super.returnConnectionToPool(jcd, con); } } catch (LookupException x) { throw x; } catch (Exception x) { throw new LookupException(x); } } public Connection getConnectionFromPool(JdbcConnectionDescriptor jcd) throws LookupException { try { Connection con; do { con = super.getConnectionFromPool(jcd); } while (con.isClosed()); return con; } catch (LookupException x) { throw x; } catch (Exception x) { throw new LookupException(x); } } --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org