Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 912688

Summary: Sometimes MDB throws NPE during receiving
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Miroslav Novak <mnovak>
Component: HornetQAssignee: Clebert Suconic <clebert.suconic>
Status: CLOSED NOTABUG QA Contact:
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: ataylor, bbaranow, csuconic, dandread, jason.greene, jdoyle, myarboro, nmaurer, pslavice
Target Milestone: ER6Keywords: Regression
Target Release: EAP 6.1.0   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-05-04 15:16:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
reproducer
none
reproducer second try
none
trace logs from second server with mdb
none
MdbWithRemoteOutQueueToContaniner1.java none

Description Miroslav Novak 2013-02-19 12:26:54 UTC
Description of problem:
If EAP 6.1.0.DR4 server is bound to IP alias then another EAP 6.1.0.DR4 server which has configured HornetQ resource adapter to connect to first server can't create connection.

On second server is deployed MDB which reads messages from "jms/queue/InQueue" and sends them to "jms/queue/OutQueue" using "java:/JmsXA" connection factory.

Strange thing is that when second server is shutdowned and started again then connection is established and MDB can read all messages.

Steps to Reproduce:
0. Download and unzip reproducer.zip from attachemnt. Next steps excexute in unzipped "reproducer" directory
1. First create an IP alias by "ifconfig eth1:0 192.168.40.1 up" under root user (change command according your environment)
2. run "sh prepare.sh"
  - dowloads EAP 6.1.0.DR4
  - creates two directories server1 and server2
  - copies directory jboss-eap-6.1 to server1 and server2
  - copies configuration standalone-full-ha-jms.xml to server1
  - copies configuration standalone-full-ha-mdb.xml to server2
  - copies mdb1.jar to server2's deployments directory
3. start first server by "sh start-server1.sh 192.168.40.1"
4. start second server by "sh start-server2.sh localhost"
5. start jms producer by "sh start-producer.sh localhost 1000"
6. see exceptions in server2 log
  
Actual results:
Following exception is thrown:
13:13:21,110 ERROR [org.hornetq.ra] (Thread-7 (HornetQ-client-global-threads-863973094)) HQ154005: Failed to deliver message: java.lang.NullPointerException
	at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:313)
	at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1016) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:52) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1161) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:106) [hornetq-core-client-2.3.0.CR1.jar:]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
	at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]

13:13:21,111 ERROR [org.hornetq.core.client] (Thread-7 (HornetQ-client-global-threads-863973094)) HQ214001: Failed to call onMessage: java.lang.NullPointerException
	at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:376)
	at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1016) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:52) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1161) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:106) [hornetq-core-client-2.3.0.CR1.jar:]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
	at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]

13:13:23,144 ERROR [org.hornetq.ra] (Thread-5 (HornetQ-client-global-threads-863973094)) HQ154005: Failed to deliver message: org.hornetq.api.core.HornetQInterruptedException: java.lang.InterruptedException
	at org.hornetq.core.remoting.impl.netty.NettyConnection.write(NettyConnection.java:244) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.protocol.core.impl.ChannelImpl.sendBlocking(ChannelImpl.java:338) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientSessionImpl.acknowledge(ClientSessionImpl.java:812) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl.doAck(ClientConsumerImpl.java:1149) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl.acknowledge(ClientConsumerImpl.java:752) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientMessageImpl.acknowledge(ClientMessageImpl.java:96) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.ra.inflow.HornetQMessageHandler.onMessage(HornetQMessageHandler.java:310)
	at org.hornetq.core.client.impl.ClientConsumerImpl.callOnMessage(ClientConsumerImpl.java:1016) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl.access$400(ClientConsumerImpl.java:52) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.core.client.impl.ClientConsumerImpl$Runner.run(ClientConsumerImpl.java:1161) [hornetq-core-client-2.3.0.CR1.jar:]
	at org.hornetq.utils.OrderedExecutorFactory$OrderedExecutor$1.run(OrderedExecutorFactory.java:106) [hornetq-core-client-2.3.0.CR1.jar:]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.6.0_24]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.6.0_24]
	at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_24]
Caused by: java.lang.InterruptedException
	at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1302) [rt.jar:1.6.0_24]
	at java.util.concurrent.Semaphore.acquire(Semaphore.java:313) [rt.jar:1.6.0_24]
	at org.hornetq.core.remoting.impl.netty.NettyConnection.write(NettyConnection.java:175) [hornetq-core-client-2.3.0.CR1.jar:]
	... 13 more

Comment 1 Miroslav Novak 2013-02-19 12:28:45 UTC
Created attachment 699417 [details]
reproducer

Comment 2 Miroslav Novak 2013-02-19 12:30:51 UTC
I did a typo in 5. step. There should be:
5. start jms producer by "sh start-producer.sh 192.168.40.1 1000"

Comment 3 Miroslav Novak 2013-02-19 13:10:02 UTC
Created attachment 699440 [details]
reproducer second try

Comment 4 Norman Maurer 2013-02-19 13:50:03 UTC
Tried to reproduce here with the reproducer.. Everything ok here.

Comment 5 Miroslav Novak 2013-02-20 08:20:16 UTC
I need to verify our environment. Looks that this is an environment issue which happens only sometimes.

Comment 6 baranowb 2013-03-27 13:02:26 UTC
This shouldnt be "NEW" issues.

Comment 7 Miroslav Novak 2013-03-29 13:17:37 UTC
I checked the source code of org.hornetq.ra.inflow.HornetQMessageHandler and it looks like that something set endpoint to null between lines 302-313:
public void onMessage(final ClientMessage message) {
...
         endpoint.beforeDelivery(HornetQActivation.ONMESSAGE); // line 302
         
         beforeDelivery = true;
         msg.doBeforeReceive();

         //In the transacted case the message must be acked *before* onMessage is called

         if (transacted)         {
            message.acknowledge();
         }

        ((MessageListener)endpoint).onMessage(msg); // line  313 - this were NPE is thrown
...
}

This happens only sometimes but looks as a problematic issue. I'll increase severity.

Comment 8 Miroslav Novak 2013-03-29 14:27:00 UTC
Created attachment 718092 [details]
trace logs from second server with mdb

Comment 9 Clebert Suconic 2013-04-01 15:26:30 UTC
Where's the source for MDB1?

Comment 10 Miroslav Novak 2013-04-01 16:21:28 UTC
Created attachment 730342 [details]
MdbWithRemoteOutQueueToContaniner1.java

Comment 11 Miroslav Novak 2013-04-01 16:23:12 UTC
Sources of MDB attached (MdbWithRemoteOutQueueToContaniner1.java)

Comment 12 Clebert Suconic 2013-04-01 17:54:55 UTC
Can you try again with hornetq CR2? I couldn't manage to recreate the environment. 

You probably already have it and can do it quickly there. Looking at the source code the endpoint is only set to null after a shutdown or an undeploy, and I don't see that happening on your testcase. or am I wrong?

Comment 13 Miroslav Novak 2013-04-02 07:05:58 UTC
This happens only sometimes on different platforms and JDKs. Tomorrow we'll get EAP 6.1.0.ER4 (HQ 2.3.0.CR2) I'll try to reproduce this issue with this build.

Comment 14 Miroslav Novak 2013-04-02 09:49:50 UTC
Anyway I'm unable to say what is causing this issue.

Comment 15 Andy Taylor 2013-04-03 10:05:37 UTC
Ive tried to recreate this issue with EAP 6.1.0.ER4 (HQ 2.3.0.CR2) to no avail, it all works ok. Looking at the code this can only happen if the MDB activation is stopped, this would either be on server shutdown or if there was some unhandled exception in the MDB and the Application server decided to remove the MDB (usually after n failures altho I am not sure). I am assuming its the latter but with out being able to reproduce it i can't say for sure or find out the underlying issue. I have looked at the logs and it does look like the RA can't connect properly so it may be an edge case issue due to a weird env.

Can you provide an environment that shows this issue so we can progress?

Comment 16 Miroslav Novak 2013-04-05 10:19:03 UTC
I did some experiments and noticed that both of the servers must be bound to IP alias.

To create IP alias for eth1 interface use commands (under root):
ifconfig eth1:0 192.168.40.1 up
ifconfig eth1:1 192.168.40.2 up

and then start servers by:
sh start-server1.sh 192.168.40.1
sh start-server2.sh 192.168.40.2

and client which sends messages to InQueue to 192.168.40.1:
sh start-producer.sh 192.168.40.1 1000

This is regression against EAP 6.0.1 where this worked without problem.

Comment 17 Andy Taylor 2013-04-06 13:06:25 UTC
i have followed these instructions and run the test successfully many times without errors. I can only assume that its environmental.

Comment 18 Miroslav Novak 2013-04-08 12:00:51 UTC
From discussion with Andy it looks that there was another node on network creating a cluster with first server. Second server with MDB tried to connect to this node in cluster which had not deployed InQueue and failed. This caused that HornetQMessageHandler.teardown was called and set endpoint to null.

Comment 19 Paul Gier 2013-04-17 20:25:23 UTC
Miroslav, is there anything else that needs to be done on this issue, or should it be resolved?

Comment 20 Clebert Suconic 2013-04-17 21:55:26 UTC
We couldn't replicate this issue at all...


But anyway, the changes I have done this week to fix SpecJMS will highly probably fix any possibility of this issue. The issue on SpecJMS was related to out of order of messages, and some issues with closing the consumers. Those fixes should eliminate any possibility of this happening.


If you have a way to check this issue, please checkout master from hornetq and take a look after replacing the jars and client jar. 


Or wait until we release master, which I already talked to Andy as he's taking care of now.

Comment 21 Miroslav Novak 2013-04-23 07:31:35 UTC
With Andy we were able to reproduce this issue in one of the workstations. Problem was that there was one more server on the network which was creating cluster with jms server and mdb server tried to connect to this other node:

Apr 08 11:55:04 <ataylor>	the issue is that the RA is connecting to both nodes
Apr 08 11:55:26 <ataylor>	one doesnt have the queue so it fails so we have a semi initialised RA
Apr 08 11:55:39 <ataylor>	which is why the endpoint is torn down and set to bnull
Apr 08 11:55:57 <ataylor>	but the succesful consumers are still receiving messages
Apr 08 11:56:45 <ataylor>	i will check further as we didnt used to load balance across nodes, so not sure why it is now
Apr 08 11:59:56 <mnovak>	from conf of server2 the HornetQ RA should connect only to server1...yes, the cluster thing is probably making a mess here
Apr 08 12:00:32 <ataylor>	yes, its a mis configuration, altho we could handle the teardown and retry better
Apr 08 12:01:01 <ataylor>	basically wre tear down all the consumers and recreat ethem, even the ones that are connected ok
Apr 08 12:01:07 <ataylor>	so it all goes haywire

Comment 22 John Doyle 2013-04-26 13:55:29 UTC
So are we closing as not a bug?

Comment 23 Miroslav Novak 2013-04-26 15:16:27 UTC
From the Clebert's comment above it seems that he did some changes which will avoid this NPE. I'll be able to verify this fix in EAP 6.1.0.ER6.

@Clebert 
Could you update the status of this bz, please?

Comment 24 Dimitris Andreadis 2013-04-26 16:22:25 UTC
Switched to ASSIGNED. Please don't forget to use the right statuses.

Comment 25 Clebert Suconic 2013-04-26 16:30:58 UTC
@Miroslav: How can I update the status on something we weren't able to replicate?


AFAIK Andy Taylor determined there was also a config issue.


And we had some issues with ordering on the queue....


I don't have any extra data on this.

Comment 26 Clebert Suconic 2013-04-26 16:31:20 UTC
I would say.. this is not a bug...

Comment 27 Miroslav Novak 2013-04-29 09:53:29 UTC
From irc discussion dev was able to replicate and investigate this issue on 08th of April. (comment 23)

This appears as a regression against EAP 6.0.1. Could you provide some info why there is a change in behavior?

Comment 28 Andy Taylor 2013-04-29 10:14:26 UTC
@miro. I thought we had already confirmed that this was happening because there was a rogue server on the lab?

Comment 29 Miroslav Novak 2013-04-29 10:39:45 UTC
Yes, but it's not happening with previous version. EAP 6.0.1 could handle such situation without problem.

Comment 30 Andy Taylor 2013-04-29 12:33:25 UTC
(In reply to comment #29)
> Yes, but it's not happening with previous version. EAP 6.0.1 could handle
> such situation without problem.

Are you saying that you had rogue servers running every time you ran the test, I don't think so. This is not an issue, the issue happened because there were other servers running on the machine that was causing issues. Please close

Comment 31 Clebert Suconic 2013-04-29 15:28:21 UTC
There was a situation when close and messages stilll coming through... done thorugh SpecJMS tests...


I don't think this will happen again...


In any case, make sure you test it with isolated clusters.. it will be hard to duplicate any test scenario you have.

Comment 32 Miroslav Novak 2013-05-04 15:16:34 UTC
Based on feedback from dev this bz will be closed. New enhancement bz#959641 where this behavior can be improved was created.