You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by rajivgandhi <ra...@gmail.com> on 2017/10/27 21:15:59 UTC
Renentrant Lock & deadlock
Hi,
In line with a deadlock reported earlier
<https://issues.apache.org/jira/browse/IGNITE-6380#> , please see below
another deadlock scenario, this time with renetrant locks:
private void start2() {
Ignite ignite = null;
try{
ignite = Ignition.start("ignite-deadlock.xml");
IgniteCache<Object, Object> cache1 =
ignite.getOrCreateCache(getConfig("cache1"));
IgniteCache<Object, Object> cache2 =
ignite.getOrCreateCache(getConfig("cache2"));
// ignite.l
CountDownLatch latch1 = new CountDownLatch(1);
CountDownLatch latch2 = new CountDownLatch(1);
Thread t = new Thread(() -> {
Lock lock = cache2.lock("fake");
try
{ lock.lock(); System.out.println("Locked"); latch1.countDown();
latch2.await(); cache1.clear(); }
catch(InterruptedException e)
{ Thread.currentThread().interrupt(); e.printStackTrace(); throw new
RuntimeException(e); }
catch(Exception e)
{ e.printStackTrace(); throw new RuntimeException(e); }
finally
{ lock.unlock(); }
});
t.start();
latch1.await();
ignite.reentrantLock("blah", true, true, true);
latch2.countDown();
t.join();
System.out.println("No deadlock");
}catch(InterruptedException e)
{ Thread.currentThread().interrupt(); e.printStackTrace(); throw new
RuntimeException(e); }
finally
{ if(ignite!=null) ignite.close(); }
}
If you could please triage and accept this as a defect.
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Renentrant Lock & deadlock
Posted by Andrey Mashenkov <an...@gmail.com>.
Hi,
ignite.reentrantLock() creates a cache for datastructures dynamically if is
not exists yet.
So, both it is same issue.
On Tue, Oct 31, 2017 at 7:15 PM, rajivgandhi <ra...@gmail.com> wrote:
> That one was with ignite.getOrCreate
> This one is with ignite.reentractLock.
>
> Are the both due to the same defect?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
--
Best regards,
Andrey V. Mashenkov
Re: Renentrant Lock & deadlock
Posted by rajivgandhi <ra...@gmail.com>.
That one was with ignite.getOrCreate
This one is with ignite.reentractLock.
Are the both due to the same defect?
--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/
Re: Renentrant Lock & deadlock
Posted by Andrey Mashenkov <an...@gmail.com>.
Hi Rajiv,
Seems, it is same issue as IGNITE-6380.
I see tread blocks on dynamic cache for ignite datastructures creation.
[1] https://issues.apache.org/jira/browse/IGNITE-6380
On Sat, Oct 28, 2017 at 12:15 AM, rajivgandhi <ra...@gmail.com>
wrote:
> Hi,
> In line with a deadlock reported earlier
> <https://issues.apache.org/jira/browse/IGNITE-6380#> , please see below
> another deadlock scenario, this time with renetrant locks:
> private void start2() {
> Ignite ignite = null;
> try{
> ignite = Ignition.start("ignite-deadlock.xml");
> IgniteCache<Object, Object> cache1 =
> ignite.getOrCreateCache(getConfig("cache1"));
> IgniteCache<Object, Object> cache2 =
> ignite.getOrCreateCache(getConfig("cache2"));
> // ignite.l
> CountDownLatch latch1 = new CountDownLatch(1);
> CountDownLatch latch2 = new CountDownLatch(1);
> Thread t = new Thread(() -> {
> Lock lock = cache2.lock("fake");
> try
> { lock.lock(); System.out.println("Locked"); latch1.countDown();
> latch2.await(); cache1.clear(); }
> catch(InterruptedException e)
> { Thread.currentThread().interrupt(); e.printStackTrace(); throw new
> RuntimeException(e); }
> catch(Exception e)
> { e.printStackTrace(); throw new RuntimeException(e); }
> finally
> { lock.unlock(); }
>
> });
> t.start();
> latch1.await();
> ignite.reentrantLock("blah", true, true, true);
> latch2.countDown();
> t.join();
> System.out.println("No deadlock");
> }catch(InterruptedException e)
> { Thread.currentThread().interrupt(); e.printStackTrace(); throw new
> RuntimeException(e); }
> finally
> { if(ignite!=null) ignite.close(); }
>
> }
>
>
> If you could please triage and accept this as a defect.
>
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
--
Best regards,
Andrey V. Mashenkov