hey all ! In Flink SQL, using the kafka connector,...
# troubleshooting
j
hey all ! In Flink SQL, using the kafka connector, is it possible to send a message to a DLQ topic, in case the connector fails to deserialize it (for instance) ? The doc says it is possible to pass
properties
to the underlying kafka client used by the connector, but apparently setting
properties.errors.deadletter.topic.name
and
properties.errors.tolerance
(see here) on the connector options in the definition of the source table does not take effet. Has anyone managed to achieve this ? Is there another way to send failed messages to a DLQ topic in a flink SQL using kafka as a source ? Thx !
plusone 1
t
You are trying to use the Kafka Connect Sink Connector options with the Flink Kafka Connector. They are not the same thing. Internally the Flink Kafka Connector uses a Kafka Producer client not a Kafka Connector.
AFAIK the SQL Kafka connector wraps the Flink Kafka Connector
j
thx for you reply @Thomas Cooper πŸ™‚ I'm a bit confused though πŸ˜… This doc I refer to is the source kafka connector, right ? And it points to the underlying kafka consumer options (which makes sense to me). Let me explain my use case again : I've got a job with a Table API Kafka connector as a source (hence the doc) and I'm trying to figure out how I can handle kafka consumer errors (ex: my connector is expecting Avro, but a bad message arrives => the connector crashes as it fails to deserialize and the job fails). I'd like to investigate options to handle that bad incoming message, send the failed message to DLQ, skip and let the job carry on. I initially thought that for this deserialization error, I could rely on passing kafka consumer
properties
as I explain above, but this does not take effect. I've had a quick look at the connector code and I think i know why : the deserialization does not seem to be delegated to the wrapped kafka consumer (so the properties are not used) => the exception is raised from flink connector (for state management and fine offset commits I imagine). But generally speaking, when the execution of such table API expression fails on a message, how can I catch this exception ? Is it possible to skip such message ? I found this thread/PR but not sure how that can be used in a Table API env (digging into this now). Does that make more sense now @Thomas Cooper? Do you know about good strategies to handle kafka source errors in a Table API env ? Thx a lot again ! I'll report here if I find new things on that πŸ™‚
t
I'm a bit confused though πŸ˜… This doc I refer to is the source kafka connector, right ? And it points to the underlying kafka consumer options (which makes sense to me).
It is quite confusing. The Flink Kafka Connector does use a Kafka Client under the hood. However, it does not use the Kafka Connect Sink Connector API which is where the DLQ option comes from. That, AFAIK, is why setting the DLQ option for the Flink connector has no effect.
So basically you can set these configs: https://kafka.apache.org/documentation/#producerconfigs
j
ok thx ! I'm looking into using a datastream source to handle deserialization errors, prior to turning this datastream into a Flink table, to use it in the rest of my job. Does not look like I can easily DLQ from a Flink table kafka source definition
t
No, from my shallow search of the JIRA/GH issues, it seems this is not possible without some lower level code to handle it
πŸ‘ 1
f
Thanks for discussing this here. Would love to hear more on your final solution. I faced the same issue with json input and ended up using
'value.json.ignore-parse-errors' = 'true'
that keeps the pipe going but have to work extra to identify and correct these bad records and move into DLQ Someone tried to address the same for avro message here https://github.com/apache/flink/pull/14444/files
j
yes I saw this config for json, but no equivalent in avro πŸ˜• I'm looking into the strategy to use datastream as a source, side_output to a DLQ in case of error and transform the main stream in a flink table to use SQL in the rest of the job. Any other idea is welcome πŸ™‚