Uploaded image for project: 'Apache Curator'
  1. Apache Curator
  2. CURATOR-276

Downgrade pattern doesn't work with "Shared Reentrant Read Write Lock"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.9.1
    • None
    • Recipes
    • None
    • Windows 7
      Java 1.7.0_60
      ZooKeeper Server 3.4.6-1569965

    Description

      Issue: Downgrade pattern doesn't block already existed WRITE lock waiters.

      Scenario:

      • First thread takes a WRITE lock and waits
      • Second thread starts and it is trying to obtain a WRITE lock. It waits because the WRITE lock is hold by the first thread.
      • First thread does downgrade:
        • Takes the READ lock
        • Releases the WRITE lock

      At this point the first thread still holds the READ lock but the second one will get the WRITE lock.

      It is reproducible for:

      • 2 threads use the same CuratorFramework instance
      • 2 threads use the different sessions
      • 2 separate JVMs

      There is attached test class: DowngradeTest.java and zoo.cfg

      Quote from Shared Reentrant Read Write Lock description
      http://curator.apache.org/curator-recipes/shared-reentrant-read-write-lock.html

      Lock Downgrading Re-entrancy also allows downgrading from the write lock to a read lock, by acquiring the write lock, then the read lock and then releasing the write lock. However, upgrading from a read lock to the write lock is not possible.
      

      Attachments

        1. zoo.cfg
          0.1 kB
          Maxim Sidnin
        2. DowngradeTest.java
          4 kB
          Maxim Sidnin

        Issue Links

          Activity

            People

              Unassigned Unassigned
              msidnin Maxim Sidnin
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: