kop
kop copied to clipboard
[BUG] Delete Topics doesn't throw PulsarAdminException or ERROR
Describe the bug Kop just throw ERROR.UNKNOWN_TOPIC_OR_PARTITION when deleting topics,not throw PulsarAdminException or Error,is not friendly to upper client.
To Reproduce Steps to reproduce the behavior:
- Frequently thow ERROR “This server does not host this topic-partition.” when executing openmessaing benchmark kafka drivers;
- Check kop log, and find perform http request of PuslarClientAdmin deleteTopics to response HTTP 500 Internal Server Error
- Check pulsar log, and find Pulsar delete topic with different type exception, such as "Topic has active producers/subscriptions" or "Failed to delete authentication policies for partitioned topic" and so on.
Expected behavior KOP could be throw pulsar exception or error to client.
Screenshots

Additional context KOP VERSION: 2.9.2.8
It can be reproduced by running a producer at first (don't exit):
$ ./bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic my-topic
>hello
>
Then try to delete the topic:
$ ./bin/kafka-topics.sh --bootstrap-server localhost:9092 --delete --topic my-topic
Error while executing topic command : This server does not host this topic-partition.
[2022-06-10 22:53:31,139] ERROR org.apache.kafka.common.errors.UnknownTopicOrPartitionException: This server does not host this topic-partition.
KOP could be throw pulsar exception or error to client.
No. The error is printed by Kafka's admin client because it received the UNKNOWN_TOPIC_OR_PARTITION error code from KoP when the topic failed to be deleted. Kafka's admin client can only receive the error code, so throwing a PulsarAdminException at KoP side is meaningless.
KOP could be throw pulsar exception or error to client.
No. The error is printed by Kafka's admin client because it received the
UNKNOWN_TOPIC_OR_PARTITIONerror code from KoP when the topic failed to be deleted. Kafka's admin client can only receive the error code, so throwing aPulsarAdminExceptionat KoP side is meaningless.
In my opinion,Kop just protocol handler between Kafka application and pulsar cluster,it's essentially to server to pulsar, and user must be skilled in pulsar operating。It's more user friendly if Kop could be provide the extension of pulsar exception, personal opinion just for your reference。
In our fork of OpenMessaging Benchmarks (datastax/openmessaging-benchmarks) we added some code to ignore the error. It happens quite often when you have multiple worker, because each worker runs the same code
https://github.com/datastax/openmessaging-benchmark/blob/7dd80e9c3f21ee83be8345259c0bfcc0fd50746c/driver-kafka/src/main/java/io/openmessaging/benchmark/driver/kafka/KafkaBenchmarkDriver.java#L107
In short, there is no way for Kafka's AdminClient to print an arbitrary error message. Kafka's AdminClient only converts the error code defined by the Kafka protocol to the string description.
It's a limitation of the Kafka client.
How to make it more friendly? Do you mean to make Kafka's client print some messages like "Topic has active producers/subscriptions"?
The only way is to change Kafka's protocol and modify Kafka's source code. KoP acts as a handler to implement Kafka's protocol. Unfortunately, Kafka's protocol doesn't define a way to accept an arbitrary error message when the delete operation failed.