You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Jon Tricker <jt...@temenos.com> on 2018/06/27 13:59:43 UTC

Problems with unlocking multiply held cache locks.

It appears that cache locks are intended to support re-entrancy. The debugger shows a count variable and the lock can be taken several times by the same node and then unlocked an equal number of times.

If a node has taken a lock several times a second node attempts to take the same lock then, as expected, it blocks. However if the first node frees the lock once the second node unlocks and both nodes end up holding the lock.

Hopefully demonstrated by the attached test code.

The information in this e-mail and any attachments is confidential and may be legally privileged. It is intended solely for the addressee or addressees. Any use or disclosure of the contents of this e-mail/attachments by a not intended recipient is unauthorized and may be unlawful. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of TEMENOS. We recommend that you check this e-mail and any attachments against viruses. TEMENOS accepts no liability for any damage caused by any malicious code or virus transmitted by this e-mail.

Re: Problems with unlocking multiply held cache locks.

Posted by Denis Mekhanikov <dm...@gmail.com>.
Andrew,

The issue, that you filed, shows a different problem. It doesn't address
lock's reentrancy.
Lock's implementation contains a counter, that tracks, how many times it
was acquired.
But it's ignored in the *unlock()* method.
So, I think, the lock shouldn't be released, until the *unlock()* method is
called an appropriate number of times.

Denis

чт, 28 июн. 2018 г. в 10:01, aealexsandrov <ae...@gmail.com>:

> Hi,
>
> As I remember we already discussed here with Jon:
>
>
> http://apache-ignite-users.70518.x6.nabble.com/If-a-lock-is-held-by-another-node-IgniteCache-isLocalLocked-appears-to-return-incorrect-results-td22110.html#a22149
>
> that isLocalLocked method works incorrectly in case if several nodes
> started
> in the same JVM. I even file the issue:
>
> https://issues.apache.org/jira/browse/IGNITE-8833
>
> In the current example, several nodes started in the same JVM too. So this
> method will not work properly.
>
> BR,
> Andrei
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

RE: Problems with unlocking multiply held cache locks.

Posted by Jon Tricker <jt...@temenos.com>.
They are separate issues. One is that the isLocalLocked() method returns incorrect results if a remote lock is held.

The other is more serious because, as Denis has commented, it means that two nodes can end up holding a lock at the same time.

Although, I appreciate, that if lock code is using the same mechanism under the covers maybe one causes the other ... i.e. when a remote lock unlocks it may trigger a previously blocked lock() call to check if the lock is held elsewhere. If that check gets an incorrect result because of the isLocalLocked() it could make the wrong decision ... leading to the second problem.

I guess we need to re-tests the second problem after the first is fixed.

-----Original Message-----
From: aealexsandrov [mailto:aealexsandrov@gmail.com]
Sent: 28 June 2018 08:02
To: user@ignite.apache.org
Subject: Re: Problems with unlocking multiply held cache locks.

Hi,

As I remember we already discussed here with Jon:

http://apache-ignite-users.70518.x6.nabble.com/If-a-lock-is-held-by-another-node-IgniteCache-isLocalLocked-appears-to-return-incorrect-results-td22110.html#a22149

that isLocalLocked method works incorrectly in case if several nodes started
in the same JVM. I even file the issue:

https://issues.apache.org/jira/browse/IGNITE-8833

In the current example, several nodes started in the same JVM too. So this
method will not work properly.

BR,
Andrei



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

The information in this e-mail and any attachments is confidential and may be legally privileged. It is intended solely for the addressee or addressees. Any use or disclosure of the contents of this e-mail/attachments by a not intended recipient is unauthorized and may be unlawful. If you have received this e-mail in error please notify the sender. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of TEMENOS. We recommend that you check this e-mail and any attachments against viruses. TEMENOS accepts no liability for any damage caused by any malicious code or virus transmitted by this e-mail.

Re: Problems with unlocking multiply held cache locks.

Posted by aealexsandrov <ae...@gmail.com>.
Hi,

As I remember we already discussed here with Jon:

http://apache-ignite-users.70518.x6.nabble.com/If-a-lock-is-held-by-another-node-IgniteCache-isLocalLocked-appears-to-return-incorrect-results-td22110.html#a22149

that isLocalLocked method works incorrectly in case if several nodes started
in the same JVM. I even file the issue:

https://issues.apache.org/jira/browse/IGNITE-8833

In the current example, several nodes started in the same JVM too. So this
method will not work properly.

BR,
Andrei



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Problems with unlocking multiply held cache locks.

Posted by Denis Mekhanikov <dm...@gmail.com>.
Cross-posting to developers list.

Guys, cache locks work inconsistently: if you take a lock twice, but
release it only once, then *IgniteCache#isLocalLocked* will tell you, that
you hold a lock, but another node will be able to acquire it.
We should either make the lock non-reentrant, or not release the cache lock
until it's unlocked the corresponding number of times.

Initial post:
http://apache-ignite-users.70518.x6.nabble.com/Problems-with-unlocking-multiply-held-cache-locks-td22317.html

Denis

ср, 27 июн. 2018 г. в 17:00, Jon Tricker <jt...@temenos.com>:

> It appears that cache locks are intended to support re-entrancy. The
> debugger shows a count variable and the lock can be taken several times by
> the same node and then unlocked an equal number of times.
>
>
>
> If a node has taken a lock several times a second node attempts to take
> the same lock then, as expected, it blocks. However if the first node frees
> the lock once the second node unlocks and both nodes end up holding the
> lock.
>
>
>
> Hopefully demonstrated by the attached test code.
>
> The information in this e-mail and any attachments is confidential and may
> be legally privileged. It is intended solely for the addressee or
> addressees. Any use or disclosure of the contents of this
> e-mail/attachments by a not intended recipient is unauthorized and may be
> unlawful. If you have received this e-mail in error please notify the
> sender. Please note that any views or opinions presented in this e-mail are
> solely those of the author and do not necessarily represent those of
> TEMENOS. We recommend that you check this e-mail and any attachments
> against viruses. TEMENOS accepts no liability for any damage caused by any
> malicious code or virus transmitted by this e-mail.
>

Re: Problems with unlocking multiply held cache locks.

Posted by Denis Mekhanikov <dm...@gmail.com>.
Cross-posting to developers list.

Guys, cache locks work inconsistently: if you take a lock twice, but
release it only once, then *IgniteCache#isLocalLocked* will tell you, that
you hold a lock, but another node will be able to acquire it.
We should either make the lock non-reentrant, or not release the cache lock
until it's unlocked the corresponding number of times.

Initial post:
http://apache-ignite-users.70518.x6.nabble.com/Problems-with-unlocking-multiply-held-cache-locks-td22317.html

Denis

ср, 27 июн. 2018 г. в 17:00, Jon Tricker <jt...@temenos.com>:

> It appears that cache locks are intended to support re-entrancy. The
> debugger shows a count variable and the lock can be taken several times by
> the same node and then unlocked an equal number of times.
>
>
>
> If a node has taken a lock several times a second node attempts to take
> the same lock then, as expected, it blocks. However if the first node frees
> the lock once the second node unlocks and both nodes end up holding the
> lock.
>
>
>
> Hopefully demonstrated by the attached test code.
>
> The information in this e-mail and any attachments is confidential and may
> be legally privileged. It is intended solely for the addressee or
> addressees. Any use or disclosure of the contents of this
> e-mail/attachments by a not intended recipient is unauthorized and may be
> unlawful. If you have received this e-mail in error please notify the
> sender. Please note that any views or opinions presented in this e-mail are
> solely those of the author and do not necessarily represent those of
> TEMENOS. We recommend that you check this e-mail and any attachments
> against viruses. TEMENOS accepts no liability for any damage caused by any
> malicious code or virus transmitted by this e-mail.
>