Francis Altomare
05/02/2024, 7:55 AMWARN org.apache.kafka.common.utils.AppInfoParser - Error registering AppInfo mbean
javax.management.InstanceAlreadyExistsException: kafka.producer:type=app-info,id=kafka producer client id
I’ve spent a bit of time debugging, and it looks like the root cause of this warning is the Flink KafkaSink creating multiple `KafkaWriter`s that, in turn, create multiple `KafkaProducer`s with the same Kafka producer client.id. Since the value for client.id is used when registering the AppInfo MBean — when multiple KafkaProducer s with the same client.id are registered we get the above InstanceAlreadyExistsException. Since we’re running with several tasks and we get a Kafka producer per task this duplicate registration exception makes sense to me.
I’m wondering if anyone here could provide some info on the impact of this exception? It’s not blocking the pipeline as the exception is caught and logged but I’m wondering if it would impact the metrics we’re able to collect from our Kafka producers. It feels like we would only end up with metrics from a single producer — whatever one ends up being registered first.
I’m also wondering if anyone has any ideas regarding workarounds. Unfortunately, due to Flink’s KafkaSink having no public constructor, I’m unable to overwrite this class and provide a unique client.id to every KafkaWriter it creates. This is a shame because when KafkaSink creates a KafkaWriter it has access to an InitContext object. This context object has an indexOfSubtask field — something I could append to the client.id making it unique.
I’m wondering if the fix would be to update the KafkaSink.builder by adding a setClientIdPrefix method, similar to what we have already on the KafkaSource.builder.
Thanks!