Hygor Knust
08/03/2023, 10:51 PMCaused by: com.esotericsoftware.kryo.KryoException: java.lang.UnsupportedOperationException
Serialization trace:
reserved (org.apache.avro.Schema$Field)
fieldMap (org.apache.avro.Schema$RecordSchema)
schema (org.apache.avro.generic.GenericData$Record)
It seems like the Kryo serializer cannot handle GenericRecords with generic schemas.
Currently my code looks like this:
static DebeziumDeserializationSchema<GenericRecord> avroParser = new DebeziumDeserializationSchema<>() {
private transient AvroData avroData;
@Override
public void deserialize(SourceRecord record, Collector<GenericRecord> out) {
if (avroData == null) {
avroData = new AvroData(2048);
}
var recordValue = record.value();
var recordSchema = record.valueSchema();
var avroRecord = (GenericRecord) avroData.fromConnectData(recordSchema, recordValue);
out.collect(avroRecord);
}
@Override
public TypeInformation<GenericRecord> getProducedType() {
return TypeInformation.of(GenericRecord.class);
}
};
// List of tables to consume
var tables = List.of(...);
var mySqlSource = MySqlSource.<GenericRecord>builder()
.hostname("host")
.port(3306)
.username("user")
.password("password")
.databaseList("database")
.tableList(String.join(",", tables))
.serverTimeZone("UTC")
.deserializer(avroParser)
.build();
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
var sourceTables = env.fromSource(mySqlSource, WatermarkStrategy.noWatermarks(), "MySQL Source");
var sink = KafkaSink.<GenericRecord>builder()
.setBootstrapServers("broker:9092")
// TODO: Route each message to its corresponding topic based on the table name - record.getSource().getName()
.setDeliveryGuarantee(DeliveryGuarantee.EXACTLY_ONCE)
.build();
sourceTables.sinkTo(sink);
Is there a way to do this?sap1ens
08/03/2023, 10:54 PMsap1ens
08/03/2023, 10:54 PMsap1ens
08/03/2023, 10:55 PMHygor Knust
08/03/2023, 10:57 PMHygor Knust
08/03/2023, 11:06 PMCaused by: com.esotericsoftware.kryo.KryoException: java.lang.UnsupportedOperationException
Serialization trace:
fields (org.apache.kafka.connect.data.ConnectSchema)
schema (org.apache.kafka.connect.data.Struct)
Kryo is still not able to serialize it.
I think the difference here is that on your example it is using scala’s createTypeInformation. It seems that this is not available in Java.sap1ens
08/03/2023, 11:08 PMenv.getConfig.enableObjectReuse()?Hygor Knust
08/03/2023, 11:10 PMHygor Knust
08/03/2023, 11:10 PMsap1ens
08/03/2023, 11:11 PMHygor Knust
08/03/2023, 11:12 PMHygor Knust
08/04/2023, 12:46 AMsap1ens
08/04/2023, 2:45 AMsap1ens
08/04/2023, 2:45 AMVitor Leal
08/20/2023, 4:01 PMfromChangelogStream) and I want to parallelize them as they're the cause of backpressure.
However, if I parallelize them, that means that a row with, say, id 0, might be routed to different "ChangelogNormalize" subtasks and create two materialized states for row with id 0. But I guess that can be solved with keyBy, ensuring every row with id 0 goes to the same "ChangelogNormalize" operator.
But my #1 worry are JOINs. AFAIK joins can't be parallelized without causing data inconsistency. Is there a way to set parallelization only for the "ChangelogNormalize" operators then?sap1ens
08/20/2023, 10:37 PMsap1ens
08/20/2023, 10:37 PMVitor Leal
08/23/2023, 12:01 PMVitor Leal
08/23/2023, 12:02 PM