From dev-return-75711-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Thu Nov 8 22:21:07 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3A80F18067A for ; Thu, 8 Nov 2018 22:21:07 +0100 (CET) Received: (qmail 42747 invoked by uid 500); 8 Nov 2018 21:21:06 -0000 Mailing-List: contact dev-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list dev@zookeeper.apache.org Received: (qmail 42736 invoked by uid 99); 8 Nov 2018 21:21:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Nov 2018 21:21:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id D1CC3C2346 for ; Thu, 8 Nov 2018 21:21:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id RX5Jjs-M4pSX for ; Thu, 8 Nov 2018 21:21:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 60C536691A for ; Thu, 8 Nov 2018 02:23:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 23AE1E13DA for ; Thu, 8 Nov 2018 02:23:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 63648266A7 for ; Thu, 8 Nov 2018 02:23:00 +0000 (UTC) Date: Thu, 8 Nov 2018 02:23:00 +0000 (UTC) From: "Hudson (JIRA)" To: dev@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (ZOOKEEPER-3162) Broken lock semantics in C client lock-recipe MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/ZOOKEEPER-3162?page=3Dcom.atlas= sian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D= 16679192#comment-16679192 ]=20 Hudson commented on ZOOKEEPER-3162: ----------------------------------- SUCCESS: Integrated in Jenkins build Zookeeper-trunk-single-thread #99 (See= [https://builds.apache.org/job/Zookeeper-trunk-single-thread/99/]) ZOOKEEPER-3162: Broken lock semantics in C client lock-recipe. (andor: rev = 477fa0724fa66cc41d14e8a974ab4ac2a1b68433) * (edit) zookeeper-recipes/zookeeper-recipes-lock/src/main/c/tests/TestClie= nt.cc * (edit) zookeeper-recipes/zookeeper-recipes-lock/src/main/c/src/zoo_lock.c * (edit) zookeeper-recipes/zookeeper-recipes-queue/build.xml * (edit) zookeeper-recipes/zookeeper-recipes-lock/build.xml * (edit) zookeeper-recipes/zookeeper-recipes-lock/src/main/c/configure.ac * (edit) zookeeper-recipes/zookeeper-recipes-queue/src/main/c/configure.ac > Broken lock semantics in C client lock-recipe > --------------------------------------------- > > Key: ZOOKEEPER-3162 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-3162 > Project: ZooKeeper > Issue Type: Bug > Components: c client > Affects Versions: 3.0.0, 3.4.13 > Reporter: Andrea Reale > Priority: Major > Labels: pull-request-available > Time Spent: 2h 20m > Remaining Estimate: 0h > > As reported (but never fixed) in the past by ZOOKEEPER-2409, ZOOKEEPER-20= 38 and (partly) ZOOKEEPER-2878, the C client lock-recipe implementation is = broken. > I identified three issues. > The main one (as also reported in the aforementioned reports) is that the= logic that goes through the lock waiting list is broken. child_floor uses = strcmp and compares the full node name (i.e., sessionID-sequence) rather th= an only comparing the sequence number. This makes it possible for two diffe= rent clients to hold the lock at the same time: assume two clients, one ass= ociated with session A, the other with session B, with A < B lexicographica= lly. Now assume that at some point a thread in B holds a lock and a thread = in A tries to acquire the same lock. A will manage to get the lock because = of the wrong comparison function, so now two guys hold the lock. > The second issue is a possible deadlock inside zkr_lock_operation. zkr_lo= ck_operation is always called by holding the mutex associated to the client= lock. In some cases, zkr_lock_operaton may decide to give-up locking and c= all zkr_lock_unlock to release the lock. When this happens, it will try to = acquire again the same phtread mutex, which will lead to a deadlock. > The third issue relates to the return value of zkr_lock_lock. According t= o the API docs, the functions returns 0 when no errors. Then it is up to th= e invoker to check when the lock is held by calling zkr_lock_isowner. Howev= er, the implementation, in case of no error, returns zkr_lock_isowner. This= is wrong because it becomes impossible to distinguish an error condition f= rom a success (but not ownerhsip). Instead the API (as described in the doc= s, btw) should return always 0 when no errors occur. > Shortly I will add the link to a PR fixing the issues. > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)