Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 746772009FB for ; Fri, 6 May 2016 15:45:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7325D160A0C; Fri, 6 May 2016 13:45:37 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id BD9CF1608F8 for ; Fri, 6 May 2016 15:45:36 +0200 (CEST) Received: (qmail 80488 invoked by uid 500); 6 May 2016 13:45:36 -0000 Mailing-List: contact dev-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list dev@activemq.apache.org Received: (qmail 80477 invoked by uid 99); 6 May 2016 13:45:35 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 May 2016 13:45:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 48295C6D3C for ; Fri, 6 May 2016 13:45:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.101 X-Spam-Level: X-Spam-Status: No, score=-5.101 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.079, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id rf_URPqB6ce3 for ; Fri, 6 May 2016 13:45:31 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 12F9D5F5A4 for ; Fri, 6 May 2016 13:45:30 +0000 (UTC) Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 362973DD47 for ; Fri, 6 May 2016 13:45:30 +0000 (UTC) Received: from dhcp-10-40-4-101.brq.redhat.com (ovpn-116-32.ams2.redhat.com [10.36.116.32]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u46DjSeg005714 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 6 May 2016 09:45:29 -0400 To: dev@activemq.apache.org Cc: Miroslav Novak From: Erich Duda Subject: Leaking threads in the Artemis test suite Message-ID: <01cff3a3-55f6-099d-e054-bea37ff5d4b7@redhat.com> Date: Fri, 6 May 2016 15:45:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="------------DF6EA4B472DBA9FABBB6F427" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 archived-at: Fri, 06 May 2016 13:45:37 -0000 --------------DF6EA4B472DBA9FABBB6F427 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi guys, I investigate test failures in the Artemis test suite and I see many "Thread leaked" issues. From stack traces It is evident that leaking threads arise from some thread pool and they are waiting for a job. Problem is that I am not able to find which thread pool owns the threads. When the default thread factory is used for creation of a thread, the name and the stack trace of thread looks following. Thread Thread[pool-4-thread-45,5,main] is still alive with the following stackTrace: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745) I suggest to do not use the Java default thread factory but we should create own default thread factory which will set up name of thread's group in such way that we could find to which thread pool the thread belongs. I have already created such thread factory and reconfigure all thread pools to use it. You can review my changes in the commit [1]. The default thread factory is implemented in the ActiveMQThreadFactory class [2]. The name and the stack trace of the thread created by this thread factory looks following. Thread Thread[Thread-0 (org.apache.activemq.artemis.tests.unit.core.paging.impl.PagingStoreImplTest-32863545),5,org.apache.activemq.artemis.tests.unit.core.paging.impl.PagingStoreImplTest-32863545] is still alive with the following stackTrace: sun.misc.Unsafe.park(Native Method) java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039) java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:442) java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1067) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1127) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745) I ran full test suite and it seems that this changes did not break anything. What do you think about it? Would it be possible to merge the commit? Thank you! Erich [1] https://github.com/dudaerich/activemq-artemis/commit/b1e48589acd9c1febd62105cc23fa4c04d673a5b [2] https://github.com/dudaerich/activemq-artemis/blob/b1e48589acd9c1febd62105cc23fa4c04d673a5b/artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ActiveMQThreadFactory.java --------------DF6EA4B472DBA9FABBB6F427--