question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[2.9.1] With partitioned topics, the Python client returns UnknownError in some cases when it should return a specific error class

See original GitHub issue

Describe the bug The Python client raises _pulsar.UnknownError: Pulsar error: UnknownError in cases when client logs indicate a specific exception code (for which there is already a specific error subclass) was recieved.

To Reproduce 0. Create a Client object with a Python logger that emits at INFO and above (e.g. logging.getLogger()).

  1. Create a persistent topic with a backlog policy that is very “short”, e.g. 1mb.
  2. With a Python producer, send messages to the topic continually until the backlog quota is hit.
  3. Observe that the Python producer errors with an UnknownError rather than ProducerBlockedQuotaExceededException.
  4. Observe that the client logs show the arrival of a ProducerBlockedQuotaExceededException event.
  5. Attempt to re-create the producer on the quota-blocked topic.
  6. Observe that the same issue occurs: logs indicate ProducerBlockedQuotaExceededException, but an UnknownError is raised.

Expected behavior Specific error classes (the exception classes distributed in the pulsar-client package) should be raised instead of UnknownError when the client can match an error event (visible in the logs) to an exception class: ProducerBlockedQuotaExceededException

I suspect the issue is with the boost-python mapping code; I don’t think class-type checks are matching correctly on C++ exception objects.

Example logs:

chariot.chariot.pulsar_client::75192::Dummy-8::WARNING 2022-04-07 18:06:35,902 [127.0.0.1:58048 -> 127.0.0.1:6650] Received error response from server: ProducerBlockedQuotaExceededException (Cannot create producer on topic with backlog quota exceeded) -- req_id: 0
chariot.chariot.pulsar_client::75192::Dummy-8::ERROR 2022-04-07 18:06:35,902 [persistent://chariot1/chariot_namespace_heartbeat/chariot_topic_heartbeat-partition-0, SynchronousChariotProducer-heartbeat-1-ZacBentleyMBP-75192] Failed to create producer: ProducerBlockedQuotaExceededException
chariot.chariot.pulsar_client::75192::Dummy-8::ERROR 2022-04-07 18:06:35,902 Unable to create Producer for partition - 0 Error - ProducerBlockedQuotaExceededException

Example stacktrace which accompanies those logs:

Traceback (most recent call last):
  File "/Users/zac.bentley/Desktop/Projects/Klaviyo/chariot/.venv/lib/python3.7/site-packages/pulsar/__init__.py", line 603, in create_producer
    p._producer = self._client.create_producer(topic, conf)
_pulsar.UnknownError: Pulsar error: UnknownError

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
BewareMyPowercommented, Apr 11, 2022

I also reproduced this bug for a partitioned topic.

2022-04-11 16:29:20.714 INFO  [0x70000f276000] ProducerImpl:189 | [persistent://public/default/my-topic-partition-0, ] Created producer on broker [127.0.0.1:64964 -> 127.0.0.1:6650] 
2022-04-11 16:29:20.714 INFO  [0x70000f276000] ProducerImpl:662 | [persistent://public/default/my-topic-partition-0, standalone-0-7] Closing producer for topic persistent://public/default/my-topic-partition-0
2022-04-11 16:29:20.714 INFO  [0x70000f276000] ProducerImpl:662 | [persistent://public/default/my-topic-partition-1, ] Closing producer for topic persistent://public/default/my-topic-partition-1
2022-04-11 16:29:20.714 INFO  [0x70000f276000] ProducerImpl:662 | [persistent://public/default/my-topic-partition-2, ] Closing producer for topic persistent://public/default/my-topic-partition-2
2022-04-11 16:29:20.714 ERROR [0x70000f276000] PartitionedProducerImpl:151 | Unable to create Producer for partition - 0 Error - ProducerBlockedQuotaExceededException
2022-04-11 16:29:20.714 ERROR [0x11352f600] SampleProducer:35 | Error creating producer: UnknownError

I will fix this issue soon.

0reactions
zbentleycommented, Apr 10, 2022

When I create a truly non-partitioned topic, the behavior is correct (I get a ResultProducerBlockedQuotaExceededException on the client). So this bug only happens for partitioned topics. I’ll update the title accordingly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

8. Errors and Exceptions — Python 3.11.1 documentation
If an exception occurs which does not match the exception named in the except clause, it is passed on to outer try statements;...
Read more >
kafka.client — kafka-python 1.4.6 documentation
[docs]class SimpleClient(object): CLIENT_ID = b'kafka-python' DEFAULT_SOCKET_TIMEOUT_SECONDS = 120 # NOTE: The timeout given to the client should always be ...
Read more >
Spring MVC Exception Handling - @ControllerAdvice ...
I have defined Employee bean as model class, however we will be using it in our application just to return valid response in...
Read more >
DefaultErrorHandler (spring-kafka 2.9.0 API) - Javadoc.io
An error handler that, for record listeners, seeks to the current offset for each topic in the remaining records. Used to rewind partitions...
Read more >
dpkp/kafka-python | Build 1281 | kafka/consumer/fetcher.py
1 from __future__ import absolute_import 30× 3 import collections 30× 4 import copy 30× 5 import logging 30×
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found