You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "jk@penguinsfan.com" <jk...@penguinsfan.com> on 2006/11/17 04:33:34 UTC

Message dispatch error

I don't think doDispatch is Queue.java is correct in the trunk.

1. If the send call (or iterate, etc.) is called simultaneously, both might
page in a separate set of messages, as returned by pageIn. Since dispatch is
called immediately, both dispatches are running at the same time and the
messages get out of order.

I think this can be fixed by NOT having pageIn return any messages. Instead,
pageIn should read the messages. Then, it could lock ANOTHER LinkedList
(e.g., dispatchList). While holding that lock, add the messages that have
been read to dispatchList. Do not return anything from pageIn. Call
doDispatch with no parameters. doDispatch locks dispatchList and copies it
into another LinkedList that is a local variable. It then clears
dispatchList and unlocks it. Then, do the dispatching from that local
variable LinkedList.

2. queueMsgConext looks like it is being used in a non-threadsafe manner, if
doDispatch can be simultaneously invoked.

3. The round robin policy is throwing exceptions when there are no
subscribers. I think the try block just needs wrapped with a check if (count
!= 0).  One way to trigger is as follows: start two consumers.  Then start a
producer.  Kill both consumers while the producer is still running.

Maybe I don't fully understand what's going on as I'm just getting started
looking at the code; if so, I apologize and will go back and be more
observant.

Exception Trace for Issue 3:

2006-11-16 22:32:46,765 [ception Handler] ERROR RoundRobinDispatchPolicy      
- Caught error rotating consumers
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
	at
edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList.remove(CopyOnWriteArrayList.java:346)
	at
org.apache.activemq.broker.region.policy.RoundRobinDispatchPolicy.dispatch(RoundRobinDispatchPolicy.java:69)
	at
org.apache.activemq.broker.region.Queue.removeSubscription(Queue.java:283)
	at
org.apache.activemq.broker.region.AbstractRegion.removeConsumer(AbstractRegion.java:271)
	at
org.apache.activemq.broker.region.RegionBroker.removeConsumer(RegionBroker.java:348)
	at
org.apache.activemq.broker.BrokerFilter.removeConsumer(BrokerFilter.java:114)
	at
org.apache.activemq.advisory.AdvisoryBroker.removeConsumer(AdvisoryBroker.java:210)
	at
org.apache.activemq.broker.BrokerFilter.removeConsumer(BrokerFilter.java:114)
	at
org.apache.activemq.broker.MutableBrokerFilter.removeConsumer(MutableBrokerFilter.java:124)
	at
org.apache.activemq.broker.TransportConnection.processRemoveConsumer(TransportConnection.java:595)
	at
org.apache.activemq.broker.TransportConnection.processRemoveSession(TransportConnection.java:632)
	at
org.apache.activemq.broker.TransportConnection.processRemoveConnection(TransportConnection.java:713)
	at
org.apache.activemq.broker.TransportConnection.stop(TransportConnection.java:887)
	at
org.apache.activemq.broker.jmx.ManagedTransportConnection.stop(ManagedTransportConnection.java:74)
	at org.apache.activemq.util.ServiceSupport.dispose(ServiceSupport.java:40)
	at
org.apache.activemq.broker.TransportConnection.serviceTransportException(TransportConnection.java:209)
	at
org.apache.activemq.broker.TransportConnection.serviceException(TransportConnection.java:241)
	at
org.apache.activemq.broker.TransportConnection$2.run(TransportConnection.java:224)


-- 
View this message in context: http://www.nabble.com/Message-dispatch-error-tf2649298.html#a7393282
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: Message dispatch error

Posted by Rob Davies <ra...@gmail.com>.
I changed the code to prevent in Queue  - to provide better  
synchronization around moving messages from the messages cursor to  
the pagedInMessages

cheers,

Rob
On 17 Nov 2006, at 23:48, jk@penguinsfan.com wrote:

>
> No, I don't have a test case for #1.  Furthermore, I realized that my
> proposed solution is incorrect and still suffers problems (race  
> conditions).
> I'll think about it some more if I get a chance.
>
>
> rajdavies wrote:
>>
>> ah - cool! thanks - it's been a difficult juggling act to avoid
>> deadlock in some of the test scenarios we have. - btw do you have a
>> test case handy for the issues 1 ?
>> I'll go back a re-check the code
>>
>> cheers,
>>
>> Rob
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Message- 
> dispatch-error-tf2649298.html#a7413138
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>


Re: Message dispatch error

Posted by "jk@penguinsfan.com" <jk...@penguinsfan.com>.
No, I don't have a test case for #1.  Furthermore, I realized that my
proposed solution is incorrect and still suffers problems (race conditions). 
I'll think about it some more if I get a chance.


rajdavies wrote:
> 
> ah - cool! thanks - it's been a difficult juggling act to avoid  
> deadlock in some of the test scenarios we have. - btw do you have a  
> test case handy for the issues 1 ?
> I'll go back a re-check the code
> 
> cheers,
> 
> Rob
> 
> 

-- 
View this message in context: http://www.nabble.com/Message-dispatch-error-tf2649298.html#a7413138
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Re: Message dispatch error

Posted by Rob Davies <ra...@gmail.com>.
ah - cool! thanks - it's been a difficult juggling act to avoid  
deadlock in some of the test scenarios we have. - btw do you have a  
test case handy for the issues 1 ?
I'll go back a re-check the code

cheers,

Rob

On 17 Nov 2006, at 03:33, jk@penguinsfan.com wrote:

>
> I don't think doDispatch is Queue.java is correct in the trunk.
>
> 1. If the send call (or iterate, etc.) is called simultaneously,  
> both might
> page in a separate set of messages, as returned by pageIn. Since  
> dispatch is
> called immediately, both dispatches are running at the same time  
> and the
> messages get out of order.
>
> I think this can be fixed by NOT having pageIn return any messages.  
> Instead,
> pageIn should read the messages. Then, it could lock ANOTHER  
> LinkedList
> (e.g., dispatchList). While holding that lock, add the messages  
> that have
> been read to dispatchList. Do not return anything from pageIn. Call
> doDispatch with no parameters. doDispatch locks dispatchList and  
> copies it
> into another LinkedList that is a local variable. It then clears
> dispatchList and unlocks it. Then, do the dispatching from that local
> variable LinkedList.
>
> 2. queueMsgConext looks like it is being used in a non-threadsafe  
> manner, if
> doDispatch can be simultaneously invoked.
>
> 3. The round robin policy is throwing exceptions when there are no
> subscribers. I think the try block just needs wrapped with a check  
> if (count
> != 0).  One way to trigger is as follows: start two consumers.   
> Then start a
> producer.  Kill both consumers while the producer is still running.
>
> Maybe I don't fully understand what's going on as I'm just getting  
> started
> looking at the code; if so, I apologize and will go back and be more
> observant.
>
> Exception Trace for Issue 3:
>
> 2006-11-16 22:32:46,765 [ception Handler] ERROR  
> RoundRobinDispatchPolicy
> - Caught error rotating consumers
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
> 	at
> edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArrayList.re 
> move(CopyOnWriteArrayList.java:346)
> 	at
> org.apache.activemq.broker.region.policy.RoundRobinDispatchPolicy.disp 
> atch(RoundRobinDispatchPolicy.java:69)
> 	at
> org.apache.activemq.broker.region.Queue.removeSubscription 
> (Queue.java:283)
> 	at
> org.apache.activemq.broker.region.AbstractRegion.removeConsumer 
> (AbstractRegion.java:271)
> 	at
> org.apache.activemq.broker.region.RegionBroker.removeConsumer 
> (RegionBroker.java:348)
> 	at
> org.apache.activemq.broker.BrokerFilter.removeConsumer 
> (BrokerFilter.java:114)
> 	at
> org.apache.activemq.advisory.AdvisoryBroker.removeConsumer 
> (AdvisoryBroker.java:210)
> 	at
> org.apache.activemq.broker.BrokerFilter.removeConsumer 
> (BrokerFilter.java:114)
> 	at
> org.apache.activemq.broker.MutableBrokerFilter.removeConsumer 
> (MutableBrokerFilter.java:124)
> 	at
> org.apache.activemq.broker.TransportConnection.processRemoveConsumer 
> (TransportConnection.java:595)
> 	at
> org.apache.activemq.broker.TransportConnection.processRemoveSession 
> (TransportConnection.java:632)
> 	at
> org.apache.activemq.broker.TransportConnection.processRemoveConnection 
> (TransportConnection.java:713)
> 	at
> org.apache.activemq.broker.TransportConnection.stop 
> (TransportConnection.java:887)
> 	at
> org.apache.activemq.broker.jmx.ManagedTransportConnection.stop 
> (ManagedTransportConnection.java:74)
> 	at org.apache.activemq.util.ServiceSupport.dispose 
> (ServiceSupport.java:40)
> 	at
> org.apache.activemq.broker.TransportConnection.serviceTransportExcepti 
> on(TransportConnection.java:209)
> 	at
> org.apache.activemq.broker.TransportConnection.serviceException 
> (TransportConnection.java:241)
> 	at
> org.apache.activemq.broker.TransportConnection$2.run 
> (TransportConnection.java:224)
>
>
> -- 
> View this message in context: http://www.nabble.com/Message- 
> dispatch-error-tf2649298.html#a7393282
> Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.
>