You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/08 07:52:16 UTC
[GitHub] [pulsar] BewareMyPower commented on issue #15078: [2.9.1] Python client returns UnknownError in some cases when it should return a specific error class
BewareMyPower commented on issue #15078:
URL: https://github.com/apache/pulsar/issues/15078#issuecomment-1092559338
It looks like it works well in my env (macOS, Python 3.9, latest code from master branch).
```
2022-04-08 15:48:43.972 INFO [0x1191ad600] ClientConnection:189 | [<none> -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
2022-04-08 15:48:43.972 INFO [0x1191ad600] ConnectionPool:96 | Created connection for pulsar://localhost:6650
2022-04-08 15:48:43.977 WARN [0x70000bfd7000] ClientConnection:436 | [<none> -> pulsar://localhost:6650] Failed to establish connection: Connection refused
2022-04-08 15:48:43.977 INFO [0x70000bfd7000] ClientConnection:375 | [127.0.0.1:62856 -> 127.0.0.1:6650] Connected to broker
2022-04-08 15:48:43.986 INFO [0x70000bfd7000] HandlerBase:64 | [persistent://public/default/topic1, ] Getting connection from pool
2022-04-08 15:48:44.132 INFO [0x70000bfd7000] ProducerImpl:189 | [persistent://public/default/topic1, ] Created producer on broker [127.0.0.1:62856 -> 127.0.0.1:6650]
2022-04-08 15:48:44.132 ERROR [0x70000bfd7000] ProducerImpl:220 | [persistent://public/default/topic1, standalone-0-2] XYZ Failed to create producer: ProducerBlockedQuotaExceededException
2022-04-08 15:48:44.133 INFO [0x70000bfd7000] ProducerImpl:635 | Producer - [persistent://public/default/topic1, standalone-0-2] , [batching = off]
Traceback (most recent call last):
File "/pulsar/pulsar-client-cpp/python/2.py", line 25, in <module>
producer = client.create_producer('topic1')
File "/pulsar/pulsar-client-cpp/python/pulsar/__init__.py", line 603, in create_producer
p._producer = self._client.create_producer(topic, conf)
_pulsar.ProducerBlockedQuotaExceededException: Pulsar error: ProducerBlockedQuotaExceededException
2022-04-08 15:48:44.136 INFO [0x1191ad600] ClientConnection:1560 | [127.0.0.1:62856 -> 127.0.0.1:6650] Connection closed
2022-04-08 15:48:44.136 INFO [0x1191ad600] ClientConnection:263 | [127.0.0.1:62856 -> 127.0.0.1:6650] Destroyed connection
```
I modified the C++ code to make producer creation always fail.
```diff
diff --git a/pulsar-client-cpp/lib/ProducerImpl.cc b/pulsar-client-cpp/lib/ProducerImpl.cc
index a539889ac00..37bd979435d 100644
--- a/pulsar-client-cpp/lib/ProducerImpl.cc
+++ b/pulsar-client-cpp/lib/ProducerImpl.cc
@@ -215,8 +215,13 @@ void ProducerImpl::handleCreateProducer(const ClientConnectionPtr& cnx, Result r
startSendTimeoutTimer();
}
- producerCreatedPromise_.setValue(shared_from_this());
-
+ // producerCreatedPromise_.setValue(shared_from_this());
+ LOG_ERROR(getName() << "XYZ Failed to create producer: "
+ << ResultProducerBlockedQuotaExceededException);
+ failPendingMessages(ResultProducerBlockedQuotaExceededException, true);
+ producerCreatedPromise_.setFailed(ResultProducerBlockedQuotaExceededException);
+ Lock lock(mutex_);
+ state_ = Failed;
} else {
lock.unlock();
```
The Python script is
```python
import pulsar
client = pulsar.Client(service_url='pulsar://localhost:6650')
producer = client.create_producer('topic1')
producer.send("hello".encode())
client.close()
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org