mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bernd Fondermann (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (VYSPER-326) Synchronizing on the BoshSessionContext for both inbound and outbound processing can lead to deadlock.
Date Sat, 22 Sep 2012 18:10:07 GMT

    [ https://issues.apache.org/jira/browse/VYSPER-326?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461231#comment-13461231
] 

Bernd Fondermann commented on VYSPER-326:
-----------------------------------------

Sounds reasonable.
However, in TRUNK, there is no longer a write0 method and my BoshBackedSessionContext has
no code in line 196.

Are you on HEAD in TRUNK?
                
> Synchronizing on the BoshSessionContext for both inbound and outbound processing can
lead to deadlock.
> ------------------------------------------------------------------------------------------------------
>
>                 Key: VYSPER-326
>                 URL: https://issues.apache.org/jira/browse/VYSPER-326
>             Project: VYSPER
>          Issue Type: Bug
>    Affects Versions: 0.7, 0.8
>            Reporter: Paul Clare
>
> This has taken some time to understand and is difficult to reproduce, the best scenerio
would be with multiplexed sessions.
> Given the two call stacks below let's asuume that we have
> alice@vysper.org/foo (qtp124427164-18) 
> alice@vysper.org/bar (qtp124427164-16) 
> For alice@vysper.org/foo the inbound bosh request aquires a lock to her BoshSession (0x000000070840e538)
> And at the same time alice@vysper.org/bar inbound request aquires a lock to her BoshSession
(0x000000070853ecd8)
>  
> In order for both threads to release the locks on their respective sessions they will
need to complete a call to LocalDeliveryUtils.relayToResourceDirectly which according to spec
will the handlers will attempt to deliver to ALL resources.
> This is where the deadlock occurs.
> alice@vysper.org/foo needs to aquire the lock to alice@vysper.org/bar session (currently
held by qtp124427164-16) to complete relayToAllResources.
> alice@vysper.org/bar needs to get a lock to alice@vysper.org/foo session (currently held
by qtp124427164-18) to complete relayToAllResources.
> In both cases the held lock is in BoshHandler.process
>    synchronized (session) {
>      ... ...
>       processSession(session, br);
> And in both cases the waiting lock is the lock on the BoshBackedSessionContext.write
>   
>    public synchronized void write(Stanza stanza) {
>      write0(boshHandler.wrapStanza(stanza));
>    }
> Currently I am use a different monitor for the outbound write to try and offset the lock
contention with the inbound processing. 
>   public void write(Stanza stanza) {
>     synchronized(writeLock) {
>       write0(boshHandler.wrapStanza(stanza));
>     }
>   }
> So inbound processing will lock on the Session and outbound writes will block on the
writeLock internal to the session.
> I Would appreciate any thoughts on this.
> "qtp124427164-18 - /bosh/":
>         at org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext.write(BoshBackedSessionContext.java:196)
>         - waiting to lock <0x000000070853ecd8> (a org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext)
>         at org.apache.vysper.xmpp.delivery.LocalDeliveryUtils.relayToResourceDirectly(LocalDeliveryUtils.java:47)
>         at org.apache.vysper.xmpp.modules.roster.handler.RosterIQHandler.pushRosterItemToInterestedResources(RosterIQHandler.java:281)
>         at org.apache.vysper.xmpp.modules.roster.handler.RosterIQHandler.handleSet(RosterIQHandler.java:220)
>         at org.apache.vysper.xmpp.modules.core.base.handler.DefaultIQHandler.executeIQLogic(DefaultIQHandler.java:73)
>         at org.apache.vysper.xmpp.modules.core.base.handler.IQHandler.executeCore(IQHandler.java:117)
>         at org.apache.vysper.xmpp.modules.core.base.handler.XMPPCoreStanzaHandler.execute(XMPPCoreStanzaHandler.java:113)
>         at org.apache.vysper.xmpp.protocol.worker.AbstractStateAwareProtocolWorker.executeHandler(AbstractStateAwareProtocolWorker.java:73)
>         at org.apache.vysper.xmpp.protocol.worker.AbstractStateAwareProtocolWorker.processStanza(AbstractStateAwareProtocolWorker.java:48)
>         at org.apache.vysper.xmpp.protocol.ProtocolWorker.processStanza(ProtocolWorker.java:191)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.processStanza(BoshHandler.java:236)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.processSession(BoshHandler.java:183)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.process(BoshHandler.java:147)
>         - locked <0x000000070840e538> (a org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshSaxContentHandler.emitStanza(BoshSaxContentHandler.java:90)
>         
> "qtp124427164-16 - /bosh/":
>         at org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext.write(BoshBackedSessionContext.java:196)
>         - waiting to lock <0x000000070840e538> (a org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext)
>         at org.apache.vysper.xmpp.delivery.LocalDeliveryUtils.relayToResourceDirectly(LocalDeliveryUtils.java:47)
>         at org.apache.vysper.xmpp.modules.core.im.handler.PresenceSubscriptionHandler.handleOutboundSubscriptionRequest(PresenceSubscriptionHandler.java:550)
>         at org.apache.vysper.xmpp.modules.core.im.handler.PresenceSubscriptionHandler.executeCorePresence(PresenceSubscriptionHandler.java:106)
>         at org.apache.vysper.xmpp.modules.core.im.handler.PresenceHandler.executeCore(PresenceHandler.java:66)
>         at org.apache.vysper.xmpp.modules.core.base.handler.XMPPCoreStanzaHandler.execute(XMPPCoreStanzaHandler.java:113)
>         at org.apache.vysper.xmpp.protocol.worker.AbstractStateAwareProtocolWorker.executeHandler(AbstractStateAwareProtocolWorker.java:73)
>         at org.apache.vysper.xmpp.protocol.worker.AbstractStateAwareProtocolWorker.processStanza(AbstractStateAwareProtocolWorker.java:48)
>         at org.apache.vysper.xmpp.protocol.ProtocolWorker.processStanza(ProtocolWorker.java:191)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.processStanza(BoshHandler.java:236)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.processSession(BoshHandler.java:183)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext.insertRequest(BoshBackedSessionContext.java:669)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshHandler.process(BoshHandler.java:138)
>         - locked <0x000000070853ecd8> (a org.apache.vysper.xmpp.extension.xep0124.BoshBackedSessionContext)
>         at org.apache.vysper.xmpp.extension.xep0124.BoshSaxContentHandler.emitStanza(BoshSaxContentHandler.java:90)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message