From dev-return-76267-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Sat Nov 24 20:59:10 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 46A2818062B for ; Sat, 24 Nov 2018 20:59:10 +0100 (CET) Received: (qmail 80006 invoked by uid 500); 24 Nov 2018 19:59:09 -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 79995 invoked by uid 99); 24 Nov 2018 19:59:09 -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; Sat, 24 Nov 2018 19:59:09 +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 C2489C218D for ; Sat, 24 Nov 2018 19:59:08 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-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 (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id M3s9S3kErJqc for ; Sat, 24 Nov 2018 19:59:07 +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 185155FC1F for ; Sat, 24 Nov 2018 19:53:01 +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 61283E0104 for ; Sat, 24 Nov 2018 19:53:00 +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 1F50721094 for ; Sat, 24 Nov 2018 19:53:00 +0000 (UTC) Date: Sat, 24 Nov 2018 19:53:00 +0000 (UTC) From: "Patrick Hunt (JIRA)" To: dev@zookeeper.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Assigned] (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.atla= ssian.jira.plugin.system.issuetabpanels:all-tabpanel ] Patrick Hunt reassigned ZOOKEEPER-3162: --------------------------------------- Assignee: Andrea Reale > 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 > Assignee: Andrea Reale > Priority: Major > Labels: pull-request-available > Fix For: 3.6.0, 3.5.5, 3.4.14 > > Time Spent: 2h 50m > 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)