[jboss-jira] [JBoss JIRA] (JGRP-2219) Deadlock: regression caused by ViewHandler change in 4.0.5

Bela Ban (JIRA) issues at jboss.org
Thu Sep 21 15:10:00 EDT 2017


    [ https://issues.jboss.org/browse/JGRP-2219?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466679#comment-13466679 ] 

Bela Ban edited comment on JGRP-2219 at 9/21/17 3:09 PM:
---------------------------------------------------------

A possible solution is to add all request to a (synchronized) queue, and make _one_ thread process that queue, by removing and processing matching requests in a loop.

h4. Pseudo code

h5. add():
{code:java}
count++; // atomic
lock
    add request to queue
    if --count == 0 && !processing:
         return processing=true;
    return false;
unlock
{code}

When add() returns true, process() is called.

h5. process()
{code:java}
loop
    while(queue is not empty):
        remove matching reqs and process them
    lock
        if( queue is empty):
            processing=false, return
        else
             continue
    unlock
end-loop
{code}


was (Author: belaban):
A possible solution is to add all request to a (synchronized) queue, and make _one_ thread process that queue, by removing and processing matching requests in a loop.

h4. Pseudo code

h5. add():
{code:java}
count++; // atomic
lock
    add request to queue
    if --count == 0 && !processing:
         processing=true;
    return processing;
unlock
{code}

When add() returns true, process() is called.

h5. process()
{code:java}
loop
    while(queue is not empty):
        remove matching reqs and process them
    lock
        if( queue is empty):
            processing=false, return
        else
             continue
    unlock
end-loop
{code}

> Deadlock: regression caused by ViewHandler change in 4.0.5
> ----------------------------------------------------------
>
>                 Key: JGRP-2219
>                 URL: https://issues.jboss.org/browse/JGRP-2219
>             Project: JGroups
>          Issue Type: Bug
>    Affects Versions: 4.0.5
>            Reporter: Bela Ban
>            Assignee: Bela Ban
>             Fix For: 4.0.7
>
>
> Deadlock caused by https://issues.jboss.org/browse/JGRP-2031:
> {noformat}
> Found one Java-level deadlock:
> =============================
> "jgroups-temp-thread-4253,EntityCollectionInvalidationTest-NodeF-59512":  waiting for ownable synchronizer 0x0000000735645138, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),  which is held by "TestDisconnectHandler-1"
> "TestDisconnectHandler-1":  waiting to lock monitor 0x00007fdff40036f8 (object 0x00000007359182d0, a org.jgroups.protocols.pbcast.Merger),  which is held by "jgroups-4,EntityCollectionInvalidationTest-NodeF-59512"
> "jgroups-4,EntityCollectionInvalidationTest-NodeF-59512":  waiting for ownable synchronizer 0x0000000735645138, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),  which is held by "TestDisconnectHandler-1"Java stack information for the threads listed above:===================================================
> "jgroups-temp-thread-4253,EntityCollectionInvalidationTest-NodeF-59512":
> 	at sun.misc.Unsafe.park(Native Method)
> 	- parking to wait for  <0x0000000735645138> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
> 	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)
> 	at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:209)
> 	at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
> 	at org.jgroups.protocols.pbcast.ViewHandler.add(ViewHandler.java:92)
> 	at org.jgroups.protocols.pbcast.GMS.up(GMS.java:841)
> 	at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:233)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:302)
> 	at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:591)
> 	at org.jgroups.protocols.FD.up(FD.java:250)
> 	at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:252)
> 	at org.jgroups.protocols.MERGE3.up(MERGE3.java:276)
> 	at org.jgroups.protocols.Discovery.up(Discovery.java:262)
> 	at org.jgroups.protocols.TP.passMessageUp(TP.java:1229)
> 	at org.jgroups.util.SubmitToThreadPool.lambda$loopback$0(SubmitToThreadPool.java:30)
> 	at org.jgroups.util.SubmitToThreadPool$$Lambda$447/1407332998.run(Unknown Source)
> 	at java.lang.Thread.run(Thread.java:748)
> "TestDisconnectHandler-1":
> 	at org.jgroups.protocols.pbcast.Merger.cancelMerge(Merger.java:431)
> 	- waiting to lock <0x00000007359182d0> (a org.jgroups.protocols.pbcast.Merger)
> 	at org.jgroups.protocols.pbcast.CoordGmsImpl.init(CoordGmsImpl.java:34)
> 	at org.jgroups.protocols.pbcast.GMS.becomeCoordinator(GMS.java:407)
> 	at org.jgroups.protocols.pbcast.ParticipantGmsImpl.handleMembershipChange(ParticipantGmsImpl.java:114)
> 	at org.jgroups.protocols.pbcast.GMS.process(GMS.java:1296)
> 	at org.jgroups.protocols.pbcast.GMS$$Lambda$95/1582906120.accept(Unknown Source)
> 	at org.jgroups.protocols.pbcast.ViewHandler.process(ViewHandler.java:173)
> 	at org.jgroups.protocols.pbcast.ViewHandler.add(ViewHandler.java:111)
> 	at org.jgroups.protocols.pbcast.GMS.up(GMS.java:841)
> 	at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:233)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:302)
> 	at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:591)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:302)
> 	at org.jgroups.protocols.FD_SOCK.up(FD_SOCK.java:245)
> 	at org.infinispan.test.hibernate.cache.util.TestDisconnectHandler.lambda$down$0(TestDisconnectHandler.java:63)
> 	at org.infinispan.test.hibernate.cache.util.TestDisconnectHandler$$Lambda$392/1960261368.run(Unknown Source)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> 	at java.lang.Thread.run(Thread.java:748)
> "jgroups-4,EntityCollectionInvalidationTest-NodeF-59512":
> 	at sun.misc.Unsafe.park(Native Method)
> 	- parking to wait for  <0x0000000735645138> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)
> 	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)
> 	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)
> 	at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:209)
> 	at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:285)
> 	at org.jgroups.protocols.pbcast.ViewHandler.resume(ViewHandler.java:140)
> 	at org.jgroups.protocols.pbcast.Merger.cancelMerge(Merger.java:435)
> 	- locked <0x00000007359182d0> (a org.jgroups.protocols.pbcast.Merger)
> 	at org.jgroups.protocols.pbcast.CoordGmsImpl.init(CoordGmsImpl.java:34)
> 	at org.jgroups.protocols.pbcast.GMS.becomeCoordinator(GMS.java:407)
> 	at org.jgroups.protocols.pbcast.GMS.installView(GMS.java:688)
> 	- locked <0x0000000735918798> (a org.jgroups.Membership)
> 	- locked <0x0000000735643d68> (a org.jgroups.protocols.pbcast.GMS)
> 	at org.jgroups.protocols.pbcast.ParticipantGmsImpl.handleViewChange(ParticipantGmsImpl.java:135)
> 	at org.jgroups.protocols.pbcast.GMS.up(GMS.java:918)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:336)
> 	at org.jgroups.protocols.pbcast.STABLE.up(STABLE.java:293)
> 	at org.jgroups.protocols.UNICAST3.up(UNICAST3.java:428)
> 	at org.jgroups.protocols.pbcast.NAKACK2.deliverBatch(NAKACK2.java:962)
> 	at org.jgroups.protocols.pbcast.NAKACK2.removeAndDeliver(NAKACK2.java:896)
> 	at org.jgroups.protocols.pbcast.NAKACK2.handleMessages(NAKACK2.java:870)
> 	at org.jgroups.protocols.pbcast.NAKACK2.up(NAKACK2.java:690)
> 	at org.jgroups.protocols.FD.up(FD.java:280)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:344)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:344)
> 	at org.jgroups.stack.Protocol.up(Protocol.java:344)
> 	at org.jgroups.protocols.TP.passBatchUp(TP.java:1255)
> 	at org.jgroups.util.MaxOneThreadPerSender$BatchHandlerLoop.passBatchUp(MaxOneThreadPerSender.java:284)
> 	at org.jgroups.util.SubmitToThreadPool$BatchHandler.run(SubmitToThreadPool.java:136)
> 	at org.jgroups.util.MaxOneThreadPerSender$BatchHandlerLoop.run(MaxOneThreadPerSender.java:273)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
> 	at java.lang.Thread.run(Thread.java:748)
> Found 1 deadlock.
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list