Hello everyone! I encountered serialization issues...
# troubleshooting
h
Hello everyone! I encountered serialization issues when performing schema update for our models. We added one integer field for our models and Flink had trouble deserializing the object from RockDB back into the new model (in a KeyedProcessFunction). We are wondering our object being non-POJO might be the issue? But why Kryo serializer cannot handle it? Data Models:
Copy code
// we store this object in MapState
public class TaskWrapper {
    private Task plannedTRTask;
    private long deletionTime;
}
public class Task {
    private String id;
    private String trackingId;
    private TaskType type; // this is an ENUM type
    private plannedRoute route;
    private int sequenceNumber;
}
public class PlannedRoute extends Route {
    private int count;
    +++ private int plannedMileage; // we were trying to add this field
}
We tried to add default kryo serializer for all of these objects above:
Copy code
execConfig.addDefaultKryoSerializer(<className>.class,
                 (Class<CompatibleFieldSerializer<className>>) (Class<?>) CompatibleFieldSerializer.class);
But we still get serialization error after making the change: 1. After flink retrieve the object(TaskWrapper) from state, plannedRoute is null (the model we modified is null). 2. one previous error with kryo serialization issue when making similar model changes (happened in onTimer):
Copy code
Caused by: org.apache.flink.util.FlinkRuntimeException: Error while deserializing the user value.
at org.apache.flink.contrib.streaming.state.RocksDBMapState$RocksDBMapEntry.getValue(RocksDBMapState.java:504)
at com.amazon.care.evaluator.processfunction.trackableeventenrichment.TREnrichmentProcessFunction.onTimer(TREnrichmentProcessFunction.java:260)
... 20 more
Caused by: java.io.EOFException: No more bytes left.
at org.apache.flink.api.java.typeutils.runtime.NoFetchingInput.require(NoFetchingInput.java:80)
at com.esotericsoftware.kryo.io.Input.readUtf8_slow(Input.java:542)
at com.esotericsoftware.kryo.io.Input.readUtf8(Input.java:535)
at com.esotericsoftware.kryo.io.Input.readString(Input.java:465)
at com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer.read(CompatibleFieldSerializer.java:57)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:761)
at org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer.deserialize(KryoSerializer.java:402)
at org.apache.flink.contrib.streaming.state.RocksDBMapState.deserializeUserValue(RocksDBMapState.java:394)
at org.apache.flink.contrib.streaming.state.RocksDBMapState.access$100(RocksDBMapState.java:65)
at org.apache.flink.contrib.streaming.state.RocksDBMapState$RocksDBMapEntry.getValue(RocksDBMapState.java:502)†
Any comments are appreciated!
t
The serialization issue you're facing with Kryo, despite using
CompatibleFieldSerializer
, could be due to several factors. Ensure that
CompatibleFieldSerializer
is applied to all classes involved, not just the top-level class. Also, make sure new fields have default values to handle objects serialized before the schema update. Double-check the Kryo configuration for correct application and consider more robust serialization frameworks like Apache Avro for schema versioning. Testing changes in a controlled environment before production deployment is crucial to identify and resolve potential issues early.
gratitude thank you 1