Any help is much appreciated! I have a running fli...
# troubleshooting
s
Any help is much appreciated! I have a running flink streaming job(flink 1.14.2) with project build say v1.0 i have enabled EmbeddedRocksDBStateBackend checkpointing Now for the my pipeline code, if i do below changes: • i have introduced one additional String field in all of the below classes: View, UserByProductAttribution, Metrics, SpTopProductMetrics • couple of new operators: there is a new Source, which .connect() with viewSocialMessagingMetrics, and this has its own CoProcessFunction with ValueState If i deploy this new code(say v2.0) ie when i restart my v1.0 job by resuming from savepoint it is failing with error NOTE: v1.0 pipeline code and error message could be found as part of thread messages
v1.0 code
Copy code
KafkaSourceView 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:
Copy code
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)
b
hi I see a similar question when using kyro for POJO’s schema evolution: https://stackoverflow.com/questions/72837295/flink-defaults-to-kryo-serialization-even-for-pojos-and-avro-specificrecords Could you try to set
env.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.
s
Thank you so much @Biao Geng for getting back, much appreciated!
Copy code
com.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)
Copy code
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)
👍 1
b
Your detailed analysis makes sense to me👍. I notice that you are using a kafka source, so if your data in kafka is not cleared due to ttl, it is possible to create a brand new job with your new codes and set the start offset to the old timestamp and start the job to re-process the data. If other logic in your codes does not rely on time-specific or random operations, I think you can avoid losing data. IMO, option2 may not be successful but you can give a try.
👍 1
s
Absolutely. your solution sounds great. Thanks !!