Return-Path: X-Original-To: apmail-curator-dev-archive@minotaur.apache.org Delivered-To: apmail-curator-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C280A1105F for ; Tue, 5 Aug 2014 18:44:12 +0000 (UTC) Received: (qmail 11928 invoked by uid 500); 5 Aug 2014 18:44:12 -0000 Delivered-To: apmail-curator-dev-archive@curator.apache.org Received: (qmail 11889 invoked by uid 500); 5 Aug 2014 18:44:12 -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 11876 invoked by uid 99); 5 Aug 2014 18:44:12 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 18:44:12 +0000 Date: Tue, 5 Aug 2014 18:44:12 +0000 (UTC) From: "Orcun Simsek (JIRA)" To: dev@curator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (CURATOR-79) InterProcessMutex doesn't clean up after interrupt 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/CURATOR-79?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13833414#comment-13833414 ] Orcun Simsek edited comment on CURATOR-79 at 8/5/14 6:43 PM: ------------------------------------------------------------- Also adding a test that fails. (slight modification of the test attached in the original thread) {code:title=Test.java|borderStyle=solid} @Test public void testInterruptDeadlock() throws Exception { CuratorFramework client = CuratorFrameworkFactory.builder() .connectString("127.0.0.1:2181") .retryPolicy(new RetryNTimes(10, 1000)) .build(); client.start(); Thread.currentThread().interrupt(); final InterProcessMutex lock = new InterProcessMutex(client, "/testInterruption4"); try { try { lock.acquire(); lock.release(); } catch (InterruptedException e) { if (lock.isAcquiredInThisProcess()) { lock.release(); } } assertTrue(lock.acquire(10, TimeUnit.MILLISECONDS)); } finally { if (lock.isAcquiredInThisProcess()) { System.out.println("Lock released successfully."); lock.release(); } } } {code} was (Author: ortschun): Also adding a test that fails. (slight modification of the test attached in the original thread) {code:title=Test.java|borderStyle=solid} @Test public void testInterruptDeadlock() throws Exception { CuratorFramework client = CuratorFrameworkFactory.builder() .connectString("127.0.0.1:2181") .retryPolicy(new RetryNTimes(10, 1000)) .build(); client.start(); Thread.currentThread().interrupt(); final InterProcessMutex lock = new InterProcessMutex(client, "/testInterruption"); try { lock.acquire(); lock.release(); } catch (InterruptedException e) { if (lock.isAcquiredInThisProcess()) { lock.release(); } } assertTrue(lock.acquire(10, TimeUnit.MILLISECONDS)); } {code} The exception: {code} java.lang.InterruptedException at java.lang.Object.wait(Native Method) at java.lang.Object.wait(Object.java:503) at org.apache.zookeeper.ClientCnxn.submitRequest(ClientCnxn.java:1309) at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:781) at com.netflix.curator.framework.imps.CreateBuilderImpl$10.call(CreateBuilderImpl.java:625) at com.netflix.curator.framework.imps.CreateBuilderImpl$10.call(CreateBuilderImpl.java:609) at com.netflix.curator.RetryLoop.callWithRetry(RetryLoop.java:106) at com.netflix.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:605) at com.netflix.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:428) at com.netflix.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:408) at com.netflix.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:41) at com.netflix.curator.framework.recipes.locks.LockInternals.attemptLock(LockInternals.java:222) at com.netflix.curator.framework.recipes.locks.InterProcessMutex.internalLock(InterProcessMutex.java:218) at com.netflix.curator.framework.recipes.locks.InterProcessMutex.acquire(InterProcessMutex.java:74) {code} > InterProcessMutex doesn't clean up after interrupt > -------------------------------------------------- > > Key: CURATOR-79 > URL: https://issues.apache.org/jira/browse/CURATOR-79 > Project: Apache Curator > Issue Type: Bug > Affects Versions: 2.0.0-incubating, 2.1.0-incubating, 2.2.0-incubating, 2.3.0 > Reporter: Orcun Simsek > Assignee: Jordan Zimmerman > > InterProcessMutex can deadlock if a thread is interrupted during acquire(). Specifically, CreateBuilderImpl.pathInForeground submits a create request to ZooKeeper, and an InterruptedException is thrown after the node is created in ZK but before ZK.create returns. ZK.create propagates a non-KeeperException, so Curator assumes the create has failed, but does not retry, and the node is now orphaned. At some point in the future, the node becomes the next in the acquisition sequence, but is not reclaimed as the ZK session has not expired. > > Curator should catch the InterruptedException and other non-KeeperExceptions, and delete the created node before propagating these exceptions. > (as originally discussed on https://groups.google.com/forum/#!topic/curator-users/9ii5of8SbdQ) -- This message was sent by Atlassian JIRA (v6.2#6252)