gaob13 / kryo

Automatically exported from code.google.com/p/kryo
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Kryo Output/Input String deserialization failed in heavy load application after 3 hours running #102

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Write a class Message with two sting type variables: field1 & field2;  and 
let it implements KryoSerializable (use writeString and readString);
1. Create a sever/client application: the server accepts client connections, 
keep creating Message objects and send to clients; the clients print out the 
received objects;
3.Start 1 server instance and 10 client instances;

What is the expected output? What do you see instead?
The server/client instances should work well without exceptions.  At the 
beginning, the system works fine util 3 hours later, the clients got underflow 
exception.

What version of the Kryo are you using?
2.18/2.20

Please provide any additional information below.

When exception happened, the client print field1 value, which actually is the 
concatenation of the field1 and field2 values. It seems that the readString 
method got the wrong length of its first string. 

Original issue reported on code.google.com by zh...@navcanada.ca on 25 Jan 2013 at 4:53

GoogleCodeExporter commented 8 years ago
Can you provide reproducible example code?

Original comment by nathan.s...@gmail.com on 6 Feb 2013 at 6:41

GoogleCodeExporter commented 8 years ago
Thank you so much for your response. The problem seems to happen when the 
system is in heavy load. We are using jGoups for our replication messaging. The 
Kryo de-serialization fails when 10 members run around 3 hours on the same 
computer.

Since of the company policy, I am sorry that I couldn't provide the code. But 
I'll try to see if I can create a sample for you.

Original comment by zh...@navcanada.ca on 12 Feb 2013 at 3:01

GoogleCodeExporter commented 8 years ago
I think I've just encountered this issue, but after some testing, I'm fairly 
certain the problem is in JGroups, not Kryo.

I have opened a bug in the JGroups JIRA: 
https://issues.jboss.org/browse/JGRP-1718

Original comment by rdicr...@lapis.com on 16 Oct 2013 at 6:08

GoogleCodeExporter commented 8 years ago
After some intense investigation (see JGRP-1718), it turns out that you 
basically can't use Kryo with JGroups right now.

The JGroups Javadoc states that the byte arrays contained in the Message object 
are assumed to be immutable. This allows them to avoid making copies of the 
byte arrays. For Kryo, this creates a problem, because it means multiple 
threads might be using the same byte array at the same time, and Kryo has to 
temporarily alter the array in order to read Strings. This creates a race 
condition where the altered array can be transmitted or re-transmitted to other 
nodes if another thread has sent the array up the stack at the same time, which 
can occur for several reasons.

If necessary, I suppose you could work around this issue by copying the byte 
array and passing the copy to Kryo, which would avoid altering the byte array 
that JGroups is using. But I'm not sure what the performance penalty for that 
would be.

Original comment by rdicr...@lapis.com on 18 Oct 2013 at 2:27