Description
Hi @novakov-alexey,
I noticed several SerializerSnapshot
cannot handle evolutions that break serialization backward compatibility because they don't serialize their version number. And so when reading back the serialized stream, they don't know which version of the serializer wrote it, to be able to react and recover from a previous version.
Identified serializer snapshots are:
CollectionSerializerSnapshot
CoproductSerializerSnapshot
MappedSerializerSnapshot
ScalaCaseObjectSerializerSnapshot
Flink provides 2 utility methods to handle this the right way without headache:
An example on how to react on different version numbers can be found here: https://github.com/apache/flink/blob/release-1.20/flink-core/src/main/java/org/apache/flink/api/common/typeutils/CompositeTypeSerializerSnapshot.java#L162
For exemple I think you could have introduced "class arity usage" feature in case class smoothly, without breaking state compatibility with previous versions. Like it is done here: https://github.com/apache/flink/blob/release-1.20/flink-core/src/main/java/org/apache/flink/api/java/typeutils/runtime/RowSerializer.java#L501
Unfortunately, there is no possibility to add usage of version number without breaking state compatibility one last time, that's why I suggest to make this change starting with Flink 2 only, as state compatibility is not an option between Flink 1 and 2 anyway.
What do you think of this?
Do you want to do it yourself, or can I propose a PR?
Thanks