Sandesh N Mendan
05/03/2024, 7:54 PMSandesh N Mendan
05/03/2024, 7:56 PMKafkaSourceView viewKafkaSource = ...
DataStreamView viewStream = viewKafkaSource
...
.name(operatorName1)
.uid(operatorName1)
.rebalance();
DataStreamUserByProductAttribution viewSocialMessagingMetrics =
viewStream
.map(SpViewEventHandler::createAttributionForSocialMessaging)
.name(operatorName2)
.uid(operatorName2)
.rebalance();
DataStreamMetrics eventMetrics =
viewSocialMessagingMetrics
.keyBy()
.window()
.reduce(new MyReduceFunction(), new MyProcessWindowFunction())
.name(operatorName3)
.uid(operatorName3)
.rebalance();
DataStreamSpTopProductMetrics topProductTupleStream =
eventMetrics
.map()
.name(operatorName4)
.uid(operatorName4);
topProductTupleStream
.sinkTo(myKafkaSink)
.name(operatorName5)
.uid(operatorName5);
and error:
com.esotericsoftware.kryo.KryoException: java.lang.IndexOutOfBoundsException: Index: 1472, Size: 2
Serialization trace:
productId (com.rr.product.events.model.UserByProductAttribution)
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125)
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:528)
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:761)
at org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer.deserialize(KryoSerializer.java:354)
at org.apache.flink.contrib.streaming.state.AbstractRocksDBAppendingState.getInternal(AbstractRocksDBAppendingState.java:64)
at org.apache.flink.contrib.streaming.state.RocksDBReducingState.add(RocksDBReducingState.java:94)
at org.apache.flink.streaming.runtime.operators.windowing.WindowOperator.processElement(WindowOperator.java:413)
at org.apache.flink.streaming.runtime.tasks.OneInputStreamTask$StreamTaskNetworkOutput.emitRecord(OneInputStreamTask.java:233)
at org.apache.flink.streaming.runtime.io.AbstractStreamTaskNetworkInput.processElement(AbstractStreamTaskNetworkInput.java:134)
at org.apache.flink.streaming.runtime.io.AbstractStreamTaskNetworkInput.emitNext(AbstractStreamTaskNetworkInput.java:105)Biao Geng
05/07/2024, 6:04 AMenv.getConfig().disableGenericTypes(); to rerun the program to see if there are any more information? It looks like that there are some serialization/deserialization issues. I am not very familiar with kryo but I found in flink’s doc, it says “*Kryo* cannot be used for schema evolution. When Kryo is used, there is no possibility for the framework to verify if any incompatible changes have been made.” I think that may be the cause of the error.Sandesh N Mendan
05/07/2024, 9:37 AMcom.esotericsoftware.kryo.KryoException: java.lang.IndexOutOfBoundsException: Index: 1472, Size: 2
Serialization trace:
productId (com.rr.product.events.model.UserByProductAttribution)
i was facing above issue because
in the UserByProductAttribution class, I have added a new String field(like i mentioned in earlier posts)
but this class right from the inception, did not follow rules for POJO type
ie in my case ,
• there was no public no-args constructor
• not all fields had getters and setters
Same applies to other classes where i introduced the same new field(Metrics, SpTopProductMetrics)
Now even after following rules in above 3 classes, i was not able to run from previous (v1.0) savepoint
got error: new serializer(PojoSerializer) is not compatible with old serializer(KryoSerializer)
org.apache.flink.util.StateMigrationException: The new state serializer (org.apache.flink.api.java.typeutils.runtime.PojoSerializer@3a27e67) must not be incompatible with the old state serializer (org.apache.flink.api.java.typeutils.runtime.kryo.KryoSerializer@17921eee).
at org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend.updateRestoredStateMetaInfo(RocksDBKeyedStateBackend.java:704)
at org.apache.flink.contrib.streaming.state.RocksDBKeyedStateBackend.tryRegisterKvStateInformation(RocksDBKeyedStateBackend.java:624)
at
ideally if we follow POJO rules in classes, it will be represented with a PojoTypeInfo and serialized with the PojoSerializer (using Kryo as configurable fallback)
ie because in v1.0 , since it did not have any POJO rules followed, it is considered as GenericType and serialized with Kryo.
Now I am left up with below possible options to try:
1. start the new code(with all rules followed); start fresh job (without savepoint) -> yes, i would lose prev state/data!!
2. new job with corrections(resume from savepoint) with following setting: env.getConfig().disableGenericTypes();
3. write our own custom serializer which should handle transformation logic to convert any datatype changes, any field removals etc (not sure what to do if Class name is modified)Biao Geng
05/07/2024, 10:12 AMSandesh N Mendan
05/07/2024, 10:27 AM