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 71C3F200B5C for ; Thu, 28 Jul 2016 02:23:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 70526160AA8; Thu, 28 Jul 2016 00:23:22 +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 B6814160A93 for ; Thu, 28 Jul 2016 02:23:21 +0200 (CEST) Received: (qmail 21586 invoked by uid 500); 28 Jul 2016 00:23:20 -0000 Mailing-List: contact dev-help@curator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@curator.apache.org Delivered-To: mailing list dev@curator.apache.org Received: (qmail 21292 invoked by uid 99); 28 Jul 2016 00:23:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2016 00:23:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id A7C0B2C0278 for ; Thu, 28 Jul 2016 00:23:20 +0000 (UTC) Date: Thu, 28 Jul 2016 00:23:20 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@curator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CURATOR-337) LeaderSelector logs stack trace with "The leader threw an exception" message erroneously MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 28 Jul 2016 00:23:22 -0000 [ https://issues.apache.org/jira/browse/CURATOR-337?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D153= 96706#comment-15396706 ]=20 ASF GitHub Bot commented on CURATOR-337: ---------------------------------------- Github user markap14 closed the pull request at: https://github.com/apache/curator/pull/158 > LeaderSelector logs stack trace with "The leader threw an exception" mess= age erroneously > -------------------------------------------------------------------------= --------------- > > Key: CURATOR-337 > URL: https://issues.apache.org/jira/browse/CURATOR-337 > Project: Apache Curator > Issue Type: Bug > Components: Client > Reporter: Mark Payne > > I am using the LeaderSelector to choose a leader for a particular role in= my cluster. Every time that I call close() on the leader selector, I end u= p with the following stack trace in my logs: > {code} > 2016-07-20 20:20:47,814 ERROR [Leader Election Notification Thread-1] o.a= .c.f.recipes.leader.LeaderSelector The leader threw an exception > java.lang.IllegalMonitorStateException: You do not own the lock: /leaders= /Cluster Coordinator > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t org.apache.curator.framework.recipes.locks.InterProcessMutex.release(Inte= rProcessMutex.java:140) ~[curator-recipes-2.10.0.jar:na] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t org.apache.curator.framework.recipes.leader.LeaderSelector.doWork(LeaderS= elector.java:425) [curator-recipes-2.10.0.jar:na] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t org.apache.curator.framework.recipes.leader.LeaderSelector.doWorkLoop(Lea= derSelector.java:441) [curator-recipes-2.10.0.jar:na] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t org.apache.curator.framework.recipes.leader.LeaderSelector.access$100(Lea= derSelector.java:64) [curator-recipes-2.10.0.jar:na] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t org.apache.curator.framework.recipes.leader.LeaderSelector$2.call(LeaderS= elector.java:245) [curator-recipes-2.10.0.jar:na] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t org.apache.curator.framework.recipes.leader.LeaderSelector$2.call(LeaderS= elector.java:239) [curator-recipes-2.10.0.jar:na] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [= na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [= na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.acce= ss$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(= ScheduledThreadPoolExecutor.java:293) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java= :1142) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.jav= a:617) [na:1.8.0_74] > =E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82=E2=80=82a= t java.lang.Thread.run(Thread.java:745) [na:1.8.0_74] > {code} > This appears to be due to the fact that in LeaderSelector.doWork(), we ca= ll mutex.acquire() and then if an InterruptedException is thrown, the final= ly block calls mutex.release() even though the mutex has not been acquired.= The finally block, then, should read: > {code} > if ( hasLeadership ) > { > hasLeadership =3D false; > try > { > mutex.release(); > } > catch ( Exception e ) > { > ThreadUtils.checkInterrupted(e); > log.error("The leader threw an exception", e); > // ignore errors - this is just a safety > } > } > {code} > That is, we should execute the body of the finally block only if hasLeade= rship =3D=3D true. -- This message was sent by Atlassian JIRA (v6.3.4#6332)