You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by andreareale <gi...@git.apache.org> on 2018/11/12 19:00:12 UTC

[GitHub] zookeeper pull request #699: ZOOKEEPER-3162 (branch3.4). Broken lock semanti...

GitHub user andreareale opened a pull request:

    https://github.com/apache/zookeeper/pull/699

    ZOOKEEPER-3162 (branch3.4). Broken lock semantics in C client lock-recipe.

    This is a new pull request that, as requested, ports PR #662 to branch-3.4
    
    This PR fixes a few issues with the C client lock-recipe, as documented in more detailed in ZOOKEEPER-3162 on JIRA.
    
    Details are also provided in the individual commits, but in short:
    - Fix a bug in the choice of the predecessor node while trying to acquire the lock
    - Fix a possible deadlock in zkr_lock_operation
    - Fix the return value of zkr_lock_lock to abide to the prescribed semantics.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ibm-research-ireland/zookeeper ZOOKEEPER-3162_branch3.4

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/zookeeper/pull/699.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #699
    
----
commit 07d5b8e3fb2b3ea5df9df9ea22fd9706da15e1d9
Author: Andrea Reale <re...@...>
Date:   2018-10-09T09:23:50Z

    Fix wrong include path for C recipes
    
    Signed-off-by: Andrea Reale <re...@ie.ibm.com>

commit 38e7266089d62ffe4ddc0dd1b0cd7632a58641fa
Author: Andrea Reale <re...@...>
Date:   2018-08-03T16:35:56Z

    Bugfix on zookeeper-recipes-lock C implementation
    
    - Fixes ZOOKEEPER-2408,ZOOKEEPER-2038, and (partly) ZOOKEEPER-2878
    - Fixes child_floor by using strcmp_suffix instead of strcmp. This will
      do the correct lookups within the sorted waiters list. Without this
      the lock semantics are broken: e.g., assuming that session A < session
      B (alfanumerically), if a thread from session B holds the lock, and a
      thread from session A tries to acquire it it will find no predecessor
      in child_floor and get the lock as well.
    - Uses binary search to find child_floor (optimization)
    
    Signed-off-by: Andrea Reale <re...@ie.ibm.com>

commit 99f5959efeb8049c5318515b5d87b6e80add35c0
Author: Andrea Reale <re...@...>
Date:   2018-10-09T14:52:11Z

    Fix return semantics of zkr_lock_lock
    
    Returns 0 (on no-errors) from zkr_lock_lock. This matches the
    API documentation. Additionall, returning zkr_lock_isowner is also
    semantically wrong: a caller might be enqueued for lock acquision and
    still not the owner; in such a case the function should still return 0
    because that is the expected behavior.
    
    Signed-off-by: Andrea Reale <re...@ie.ibm.com>

commit b33a0bf8545f089a9f29c43414125032a2b5c1d3
Author: Andrea Reale <re...@...>
Date:   2018-08-15T16:35:07Z

    Fixes deadlock in zoo_lock_operation
    
    zkr_lock_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 call 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.
    
    This commit fixes the issue by calling a non-protected version of
    zkr_lock_unlock from within zkr_lock_operatino.
    
    Signed-off-by: Andrea Reale <re...@ie.ibm.com>

----


---

[GitHub] zookeeper issue #699: ZOOKEEPER-3162 (branch3.4). Broken lock semantics in C...

Posted by andreareale <gi...@git.apache.org>.
Github user andreareale commented on the issue:

    https://github.com/apache/zookeeper/pull/699
  
    @anmolnar , as requested this is a duplicate of PR #662 ported onto branch-3.4.
    It applied cleanly except for the calls to the logging macros, which in 3.5 support logging by callback as far as I understood.
    Thanks!


---

[GitHub] zookeeper issue #699: ZOOKEEPER-3162 (branch3.4). Broken lock semantics in C...

Posted by anmolnar <gi...@git.apache.org>.
Github user anmolnar commented on the issue:

    https://github.com/apache/zookeeper/pull/699
  
    Committed. Thanks @andreareale !
    Please assign the jira to yourself and close this PR.


---