Bug 1169348 - [GSS](6.4.z) java.lang.IndexOutOfBoundsException: Not enough readable bytes - Need 409600, maximum is 310758
Summary: [GSS](6.4.z) java.lang.IndexOutOfBoundsException: Not enough readable bytes -...
Keywords:
Status: CLOSED EOL
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: HornetQ
Version: 6.4.0
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: GA
: EAP 6.4.0
Assignee: Yong Hao Gao
QA Contact: Miroslav Novak
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-12-01 12:06 UTC by Miroslav Novak
Modified: 2020-05-14 14:57 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-19 12:46:32 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Miroslav Novak 2014-12-01 12:06:35 UTC
Description of problem:

Sometimes there is exception in standalone JMS client which is consuming messages from queue in following scenario:

1. Start 2 EAP 6.4.0.DR11 server in collocated topology with replicated journal
   - there is queue jms/queue/testQueue0 deployed
2. Start 3 producers and 1 consumer with transacted session connected to 1st server and sending/receiving messages to/from testQueue0
3. Kill 1st EAP server and wait for clients to failover to backup to 2nd server
4. Start 1st EAP server again and wait for clients to failback
5. Stop producers and wait for consumer to receive all messages from testQueue0
6. Verify number of send and received messages

Problem occurs in step 5. when producers are stopped. IndexOutOfBoundsException is thrown in consumer:

java.lang.IndexOutOfBoundsException: Not enough readable bytes - Need 409600, maximum is 310758
        at org.jboss.netty.buffer.AbstractChannelBuffer.checkReadableBytes(AbstractChannelBuffer.java:661)
        at org.jboss.netty.buffer.AbstractChannelBuffer.readBytes(AbstractChannelBuffer.java:338)
        at org.jboss.netty.buffer.AbstractChannelBuffer.readBytes(AbstractChannelBuffer.java:344)
        at org.hornetq.core.buffers.impl.ChannelBufferWrapper.readSimpleStringInternal(ChannelBufferWrapper.java:71)
        at org.hornetq.core.buffers.impl.ChannelBufferWrapper.readNullableSimpleString(ChannelBufferWrapper.java:49)
        at org.hornetq.jms.client.HornetQTextMessage.doBeforeReceive(HornetQTextMessage.java:141)
        at org.hornetq.jms.client.HornetQMessageConsumer.getMessage(HornetQMessageConsumer.java:232)
        at org.hornetq.jms.client.HornetQMessageConsumer.receive(HornetQMessageConsumer.java:129)
        at org.jboss.qa.hornetq.apps.clients.ReceiverTransAck.receiveMessage(ReceiverTransAck.java:341)
        at org.jboss.qa.hornetq.apps.clients.ReceiverTransAck.run(ReceiverTransAck.java:130)


How reproducible:

To reproduce the problem follow those steps:
clone our testsuite from git:
git://git.app.eng.bos.redhat.com/jbossqe/eap-tests-hornetq.git

Go to eap-tests-hornetq/scripts and run groovy script PrepareServers.groovy with -DEAP_VERSION=6.4.0.DR11 parameter:
groovy -DEAP_VERSION=6.4.0.DR11 PrepareServers.groovy

(Script will prepare 4 servers - server1..4 in the directory where are you currently standing.)

Export these paths and also mcast addresse.:
export JBOSS_HOME_1=$PWD/server1/jboss-eap
export JBOSS_HOME_2=$PWD/server2/jboss-eap
export JBOSS_HOME_3=$PWD/server3/jboss-eap
export JBOSS_HOME_4=$PWD/server4/jboss-eap
export MCAST_ADDR=235.3.4.5

Go to jboss-hornetq-testsuite/ in our testsuite and run
mvn install -Dtest=ReplicatedColocatedClusterFailoverTestCase#testFailbackTransAckQueue

Actual results:
IndexOutOfBoundsException is thrown in consumer

Expected results:
IndexOutOfBoundsException should not be thrown.

Comment 1 Justin Bertram 2015-01-06 23:03:45 UTC
When I run ReplicatedColocatedClusterFailoverTestCase#testFailbackTransAckQueue I don't see an IndexOutOfBoundsException.  Are you sure this is the correct test?  I noticed it's the same one referenced on BZ1169418.

Comment 2 Miroslav Novak 2015-01-07 10:48:11 UTC
Unfortunately this is one of the "random" failures. It's really rare and I don't have 100% reproducer. Test must be run multiple times. Issue in bz#1169418 is also one of the sometimes problems but based on observation of Jenkins runs, there it occurs more often.

Comment 3 Yong Hao Gao 2015-01-09 12:49:23 UTC
Hi Mirek,

My first run of the test didn't get the IndexOutOfBoundsException, however I've seen the timeout exception as you reported in bz#1169418.

I'll do some more investigation.

Howard

Comment 4 Yong Hao Gao 2015-01-21 14:31:21 UTC
Hi Mirek,

Today I just found there might be a problem in the test case. If I am right the test starts three producers to produce messages. Each producer takes a messageBuilder. The problem is that each producer is running on its own thread, and the messageBuilder is shared among producers. However the methods in messageBuilder such as createMessage(session) are not synchronized, which may cause potential problem.

Please see QueueClientsTransAck.startClients():

...
for (int producerNumber = 0; producerNumber < getNumberOfProducersPerQueueu(); producerNumber++) {

p = new ProducerTransAck(container, getHostnameForProducers(), getJndiPort(), getQueueJndiNamePrefix() + destinationNumber, getMessages(), this);

if (messageBuilder != null) {
     p.setMessageBuilder(messageBuilder);
}
.....

You can see all ProducerTransAck uses the same messageBuilder ( in the test it is an instance of ClientMixMessageBuilder class).

What do you think? 

Howard

Comment 5 Miroslav Novak 2015-01-21 15:18:12 UTC
Hi Howard,

messageBuilder is really shared among producers. Here each producer has its own session created from its own connection. When messageBuilder.createMessage(session) is called in producer thread then it's passing its session to messageBuilder and there is used to create message. I went through ClientMixMessageBuilder.createMessage class and this could only affect "counter" variable so 2 messages would have same property counter. Which is harmless.
I don't think this could cause IndexOutOfBoundException because it's thrown on receiver side. Receiver has its own connection and session.

Thanks,
Mirek

Comment 6 Yong Hao Gao 2015-01-21 15:22:25 UTC
Hi Mirek,

How about this method getNextMapKey() ? It uses a member mapMessageKey which is changed possible concurrently.

Howard

Comment 7 Miroslav Novak 2015-01-21 15:48:05 UTC
Hi Howard,

yes, string variable mapMessageKey can be also changed concurrently. I'm not sure whether it can influence how receiver is allocating buffer. If producer sets message.setObject(mapMessageKey, stringContent) and then before send another thread changes mapMessageKey. 

Mirek

Comment 8 Yong Hao Gao 2015-01-21 15:53:52 UTC
Hi Mirek,

I'm still not clear about how's going wrong. I've been chasing the possible issues for the last few days and didn't get much progress. The only thing I'm a bit sure about is that there is some exception out of the client message builder class.

I'd suggest we keep the code synchronized and run the test again, and see what can we get.

Howard

Comment 9 Yong Hao Gao 2015-01-21 15:57:35 UTC
Hi Mirek,

Just for your info, I've just seen the 'out of index' exception at this line:

int numericValueOfLastCharacter = mapMessageKey.codePointAt(mapMessageKey.length() - 1);

That probably is cause by concurrent modification.

I'll try synchronize the createMessage() method and re-run the test. I'll give you some update tomorrow. 


Howard

Comment 10 Miroslav Novak 2015-01-22 08:54:26 UTC
Hi Howard,

ok, I'll do the same thing and run our jobs in Jenkins again. Unfortunately there is rare occurrence of this. The other bz#1169418 is much easier to hit.

Mirek

Comment 11 Yong Hao Gao 2015-01-23 02:50:29 UTC
That's great Mirek. For me I'm still seeing strange IndexOutOfBound error after I synchronized createMessage() method. I'm investigating...

Howard


Note You need to log in before you can comment on or make changes to this bug.