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
If the error is not handled or carefully propagated, additional calls into the Python/C API may not behave as intended and may fail in mysterious ways.
Consider a case where Logger.log raises an exception, thus, setting the python error indicator. In the next log_cb invocation by librdkafka, this library would again call Logger.log without handling the previous error. Because of this, method calls returns a misleading SystemError which is difficult to catch in a python application.
How to reproduce
We see this issue consistently when SIGINT is sent to a process which is polling the Consumer. Logger.log raises a KeyboardInterrupt which isn't handled before calling Logger.log again. We can't share our proprietary application so here's a minimal reproducer using a mock Logger class to easily reproduce the issue (we see the issue with the default Logger class):
[nix-shell:/codemill/krishan/maestro-api]$ python cf_gh_issue.py |& head -100
creating consumer
consumer created
polling
Traceback (most recent call last):
File "/codemill/krishan/maestro-api/cf_gh_issue.py", line 21, in log
raise KeyboardInterrupt
KeyboardInterrupt
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/codemill/krishan/maestro-api/cf_gh_issue.py", line 21, in log
raise KeyboardInterrupt
SystemError: <class 'KeyboardInterrupt'> returned a result with an exception set
This SystemError is misleading.
Checklist
Please provide the following information:
confluent-kafka-python and librdkafka version: 2.3.0
Apache Kafka broker version: 3.0.0
Client configuration: debug=all
Operating system: Red Hat Enterprise Linux 8.9
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 library calls Python APIs (
Logger.log
specifically) without checking whether the Python error indicator was set.confluent-kafka-python/src/confluent_kafka/src/confluent_kafka.c
Line 1834 in 5a87879
As Python docs,
Consider a case where
Logger.log
raises an exception, thus, setting the python error indicator. In the nextlog_cb
invocation bylibrdkafka
, this library would again callLogger.log
without handling the previous error. Because of this, method calls returns a misleadingSystemError
which is difficult to catch in a python application.How to reproduce
We see this issue consistently when SIGINT is sent to a process which is polling the
Consumer
.Logger.log
raises aKeyboardInterrupt
which isn't handled before callingLogger.log
again. We can't share our proprietary application so here's a minimal reproducer using a mock Logger class to easily reproduce the issue (we see the issue with the defaultLogger
class):Running this would show this:
This
SystemError
is misleading.Checklist
Please provide the following information:
2.3.0
debug=all
Red Hat Enterprise Linux 8.9
'debug': '..'
as necessary)The text was updated successfully, but these errors were encountered: