curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Maxim Sidnin (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (CURATOR-276) Downgrade pattern doesn't work with "Shared Reentrant Read Write Lock"
Date Wed, 04 Nov 2015 08:22:27 GMT

     [ https://issues.apache.org/jira/browse/CURATOR-276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Maxim Sidnin updated CURATOR-276:
---------------------------------
    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 be first thread.
- First thread does downgrade:
-- Takes the READ lock
-- Releases the WRITE lock

(x) 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

(i) There is attached test class: *DowngradeTest.java* and zoo.cfg

(i) Quote from Shared Reentrant Read Write Lock description ([link:http://curator.apache.org/curator-recipes/shared-reentrant-read-write-lock.html]):
{code}
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.
{code}

  was:
*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 be first thread.
- First thread does downgrade:
-- Takes the READ lock
-- Releases the WRITE lock
(x) 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

(i) Quote from Shared Reentrant Read Write Lock description ([link:http://curator.apache.org/curator-recipes/shared-reentrant-read-write-lock.html]):
{code}
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.
{code}


> Downgrade pattern doesn't work with "Shared Reentrant Read Write Lock"
> ----------------------------------------------------------------------
>
>                 Key: CURATOR-276
>                 URL: https://issues.apache.org/jira/browse/CURATOR-276
>             Project: Apache Curator
>          Issue Type: Bug
>          Components: Recipes
>    Affects Versions: 2.9.1
>         Environment: Windows 7
> Java 1.7.0_60
> ZooKeeper Server 3.4.6-1569965
>            Reporter: Maxim Sidnin
>         Attachments: DowngradeTest.java, zoo.cfg
>
>
> *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 be first thread.
> - First thread does downgrade:
> -- Takes the READ lock
> -- Releases the WRITE lock
> (x) 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
> (i) There is attached test class: *DowngradeTest.java* and zoo.cfg
> (i) Quote from Shared Reentrant Read Write Lock description ([link:http://curator.apache.org/curator-recipes/shared-reentrant-read-write-lock.html]):
> {code}
> 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.
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message