Description
MyBatis version
3.4.6
Database vendor and version
MySql 8.0.32
Test case or example project
Don't have one.
Steps to reproduce
Haven't figured that out yet.
Expected result
A cached result that completes
Actual result
A cached result that never finishes deserializing
We have a situation where on occasion, we'll have an Out of Memory error and our server process will hang.
We've taken a memory dump of the process and analyzed it with VisualVM. The analysis shows that our largest held objects are byte[]
's. When looking at the byte array information it comes in the format of...
Our largest offenders are 500mb each (which, by itself, seems suspect). When looking at what has a reference to that, it is a HashMap
I decided to save the byte[] of one of these cached values to disk. I created a small console program to read that file and feed it to the equivalent of this (I copy / pasted most of this into my console program)
private Serializable deserialize(byte[] value) {
SerialFilterChecker.check();
Serializable result;
try (ByteArrayInputStream bis = new ByteArrayInputStream(value);
ObjectInputStream ois = new CustomObjectInputStream(bis)) {
result = (Serializable) ois.readObject();
} catch (Exception e) {
throw new CacheException("Error deserializing object. Cause: " + e, e);
}
return result;
}
The deserialization pretty much never ends (it's been over an hour).
This sounds like a recursive loop with some sort of deep circular reference. Is there a situation in the cache deserialization that would allow for such a thing?
I can state that I know we load a lot of associations. Again, against better judgement, those associations load their associations, etc. so the object graph is likely deep.