Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 89392 invoked from network); 20 Mar 2011 19:50:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 20 Mar 2011 19:50:28 -0000 Received: (qmail 15726 invoked by uid 500); 20 Mar 2011 19:50:27 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 15464 invoked by uid 500); 20 Mar 2011 19:50:27 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 15456 invoked by uid 99); 20 Mar 2011 19:50:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Mar 2011 19:50:27 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Mar 2011 19:50:27 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 069903B176B for ; Sun, 20 Mar 2011 19:50:06 +0000 (UTC) Date: Sun, 20 Mar 2011 19:50:06 +0000 (UTC) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Message-ID: <75556770.7.1300650606022.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <842551904.8056.1299682379438.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (POOL-184) Premature starvation in GenericObjectPool when borrowObject() and evict() are executed concurrently MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/POOL-184?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Phil Steitz updated POOL-184: ----------------------------- Fix Version/s: 1.5.6 > Premature starvation in GenericObjectPool when borrowObject() and evict() are executed concurrently > --------------------------------------------------------------------------------------------------- > > Key: POOL-184 > URL: https://issues.apache.org/jira/browse/POOL-184 > Project: Commons Pool > Issue Type: Bug > Affects Versions: 1.5.5 > Environment: java 1.6.0_24 > Ubuntu 10.10 > Reporter: Adrian Nistor > Fix For: 1.5.6 > > Attachments: Test01.java, stall.txt > > > Hi, > I am encountering a deadlock in GenericObjectPool. It appears in version 1.5.5 > and also in revision 1079385 (March 8th 2011). > The deadlock manifests when calling borrowObject() and evict() in parallel. I > have inlined a test that exposes this problem. For this test, the expected > output is: > Expected output: > 0 > 1 > 2 > 3 > 4 > ..... > 498 > 499 > DONE > But when the bug manifests (almost always for this test), the output is: > Bug output: > 0 > 1 > 2 > 3 > 4 > When the bug manifests, the test does not finish, it just gets stuck after > printing several values (in this run: 0 1 2 3 4, but in other runs may be > 0 1 2 .. 18 or 0 1 2 or some other value). > When the loop limit is small (e.g., 11 instead of 5000), the test does finish. > Also, when running sequentially: > > Pool.borrowObject(); > Pool.evict(); > or vice-versa > Pool.evict(); > Pool.borrowObject(); > the test still finishes. > Is this a bug? Is there a patch for it? > Thanks! > Adrian > ================================================================================ > This test is for version 1.5.5. For revision 1079385 one should replace > setMaxActive() with setMaxTotal() > ================================================================================ > package org.apache.commons.pool.impl; > import org.apache.commons.pool.PoolableObjectFactory; > public class Test01 > { > public static void main(String[] args) throws Exception > { > Test01 test = new Test01(); > test.test(); > } > > SimpleFactory Factory = null; > GenericObjectPool Pool = null; > Object Obj = null; > public void test() throws Exception > { > Factory = new SimpleFactory(); > Pool = new GenericObjectPool(Factory); > Pool.setMaxActive(1); > Pool.addObject(); > > for(int i=0; i<5000; i++) > { > Thread one = new MyThread(1); > Thread two = new MyThread(2); > one.start(); > two.start(); > one.join(); > two.join(); > > Pool.returnObject(Obj); > if(i%10==0) > { > System.out.println(i/10); > } > } > System.out.println("DONE"); > } > private class MyThread extends Thread > { > int _tid; > public MyThread(int tid) > { > _tid = tid; > } > public void run() > { > try > { > if(_tid == 1) > { > Obj = Pool.borrowObject(); > } > if (_tid == 2) > { > try > { > Pool.evict(); > } catch (Exception e) {} > } > } > catch(Exception e) > { > throw new RuntimeException(e); > } > } > } > private class SimpleFactory implements PoolableObjectFactory > { > public SimpleFactory() {} > public Object makeObject() { return new String("testing"); } > public void destroyObject(Object obj) {} > public boolean validateObject(Object obj) {return true;} > public void activateObject(Object obj) throws Exception {} > public void passivateObject(Object obj) throws Exception {} > public boolean isThrowExceptionOnActivate() {return true;} > } > } > ================================================================================ -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira