You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behavior of the confluent_kafka.cimpl.KafkaError object is somewhat unusual. The documentation mentions it serves multiple purposes, and it seems itself is not an exception. However, unlike other exceptions that must be derived from builtins.BaseException, Python doesn't complain any issues when you attempt to raise an instance of this class.
>>>fromconfluent_kafkaimportKafkaError>>>raiseKafkaError(-195)
# Nothing will raises here, and also Python interpreter doesn't complain about>>> [issubclass(KafkaError, BaseException), isinstance(KafkaError(-195), BaseException)]
[False, False]
>>>classSentinel: pass>>>raiseSentinel() # Expected behaviour, if the object is not an exceptionTypeError: exceptionsmustderivefromBaseException
However, similar to other Exceptions, you can catch it:
Fortunately, I haven't seen the confluent_kafka.cimpl.KafkaError object being directly raised by the client itself, which suggests it is safe in that regard because it cannot be catched with builtins.Exception class. However, this object is used as an argument in several callbacks that can be registered with confluent_kafka.Consumer or confluent_kafka.Producer, such as error_cb, on_delivery, and on_commit. In these instances, attempting to log any exceptions with traceback, even if within your logic, can result in the worker thread being terminated.
While the consumer worker is still running, if the Kafka broker is restarted, an error of type KafkaError occurs (i.e. KafkaError(-195)), the next call to consumer.poll triggers the worker's thread termination due to logging the exception traceback within the kafka_error_cb callback. Although I haven't tested this, But if you implement your logic within these callbacks and attempt to catch and log those exceptions, it may behave similarly and cause the thread to terminate.
Checklist
Please provide the following information:
confluent-kafka-python and librdkafka version (confluent_kafka.version() and confluent_kafka.libversion()): 2.6.1
Apache Kafka broker version: 3.7
Client configuration: {...}
Operating system: linux-debain-bookworm
Provide client logs (with 'debug': '..' as necessary)
Provide broker log excerpts
Critical issue
The text was updated successfully, but these errors were encountered:
Description
The behavior of the
confluent_kafka.cimpl.KafkaError
object is somewhat unusual. The documentation mentions it serves multiple purposes, and it seems itself is not an exception. However, unlike other exceptions that must be derived frombuiltins.BaseException
, Python doesn't complain any issues when you attempt to raise an instance of this class.However, similar to other
Exceptions
, you can catch it:But if you catch it, and also want to log the traceback, you can't:
Fortunately, I haven't seen the
confluent_kafka.cimpl.KafkaError
object being directly raised by the client itself, which suggests it is safe in that regard because it cannot be catched withbuiltins.Exception
class. However, this object is used as an argument in several callbacks that can be registered withconfluent_kafka.Consumer
orconfluent_kafka.Producer
, such aserror_cb
,on_delivery
, andon_commit
. In these instances, attempting to log any exceptions with traceback, even if within your logic, can result in the worker thread being terminated.How to reproduce
While the consumer worker is still running, if the Kafka broker is restarted, an error of type
KafkaError
occurs (i.e.KafkaError(-195)
), the next call toconsumer.poll
triggers the worker's thread termination due to logging the exception traceback within thekafka_error_cb
callback. Although I haven't tested this, But if you implement your logic within these callbacks and attempt to catch and log those exceptions, it may behave similarly and cause the thread to terminate.Checklist
Please provide the following information:
confluent_kafka.version()
andconfluent_kafka.libversion()
): 2.6.1{...}
'debug': '..'
as necessary)The text was updated successfully, but these errors were encountered: