flix-tech / webfleet-kafka-connector

This is a kafka connector consuming messages from TomTom webfleet API.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java.lang.IllegalArgumentException: A metric named 'MetricName already exists, can't register another one.

geopamplona opened this issue · comments

Hi,
After playing with Webfleet Kafka Connector I'm getting following Exception.
After connect restarting everything is OK. I don't know how to reproduce this again, but it this happens frequently when changing connector properties

java.lang.IllegalArgumentException: A metric named 'MetricName [name=offset-commit-max-time-ms, group=connector-task-metrics, description=The maximum time in milliseconds taken by this task to commit offsets., tags={connector=WebfleetSourceConnector2, task=0}]' already exists, can't register another one.
	at org.apache.kafka.common.metrics.Metrics.registerMetric(Metrics.java:532)
	at org.apache.kafka.common.metrics.Sensor.add(Sensor.java:256)
	at org.apache.kafka.common.metrics.Sensor.add(Sensor.java:241)
	at org.apache.kafka.connect.runtime.WorkerTask$TaskMetricsGroup.<init>(WorkerTask.java:328)
	at org.apache.kafka.connect.runtime.WorkerTask.<init>(WorkerTask.java:69)
	at org.apache.kafka.connect.runtime.WorkerSourceTask.<init>(WorkerSourceTask.java:100)
	at org.apache.kafka.connect.runtime.Worker.buildWorkerTask(Worker.java:445)
	at org.apache.kafka.connect.runtime.Worker.startTask(Worker.java:404)
	at org.apache.kafka.connect.runtime.distributed.DistributedHerder.startTask(DistributedHerder.java:852)
	at org.apache.kafka.connect.runtime.distributed.DistributedHerder.access$1600(DistributedHerder.java:108)
	at org.apache.kafka.connect.runtime.distributed.DistributedHerder$13.call(DistributedHerder.java:866)
	at org.apache.kafka.connect.runtime.distributed.DistributedHerder$13.call(DistributedHerder.java:862)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

Hello @geopamplona are u deleting the old connector before starting a new one?

Hello, this looks like an error while registering JMX metrics in Kafka connect.
Can you give me more details regarding on how are you running the three connectors? One cluster or multiple clusters?

Can you pls check using REST /connectors when you get this error is there a connect running with WebfleetSourceConnector2 name.

I'm running 3 connectors in the same instance of kafka-connect, I do not use cluster; Each connector has different accounts configured and different name
occurs if I do restart a webfleet connector, when refreshing, another connector usually stops with this error
it is quite serious in production environments

there is a similar bug reported with same error https://issues.apache.org/jira/browse/KAFKA-6252

edit:
there are no tests for the metrics, it could be an opportunity to prepare them

Now I understand the problem better, the kafka connector tries to register a metric that already exists.
I can think of two ideas:

  • Could you make the BaseMetrics class only register the name of the metric if it does not exist?
  • Would it be worth registering metrics for each connector or topic? with different names, that is, each metric replicate it by topic or connector name.

it's a kafka error
It is not appropriate to report it here

Hello @geopamplona , thanks for your input. Sorry for the late reply, just came back from holidays.
Can you please attach which kafka error are you talking about here?