apache / apache/pulsar-client-python

python client does not retry when get topic partition metadata to create producer fails

Abierto
#113 5 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
75
Forks
53
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Describe the bug**
If you fail to get topic partition metadata through service_url, it will not retry and try to connect to other ip, and will directly exit abnormally after the connection fails
pulsar-client=2.9.4

**To Reproduce**
1、Test Conditions
127.0.0.1:6650 The corresponding service is closed
127.0.0.2:6650 service is normal
2、Test code
```
import pulsar
client = pulsar.Client(
authentication=pulsar.AuthenticationToken(
"xxxxxxxxxxxx"),
service_url="pulsar://127.0.0.1:6650,127.0.0.2:6650",
#operation_timeout_seconds=120
)
producer = client.create_producer(
topic='persistent://qlm-test/qlm-ns/python-test3',
send_timeout_millis=120000,
block_if_queue_full=True,
batching_enabled=True,
batching_max_publish_delay_ms=10,
batching_max_messages=100,
batching_max_allowed_size_in_bytes=1024 * 1024,
max_pending_messages=1000)

while(True):
producer.send(('Hello-%d').encode('utf-8'))
producer.close()
client.close()
```

**error log**
```
2023-04-25 14:16:51.866 INFO [139745917667072] ExecutorService:41 | Run io_service in a single thread
2023-04-25 14:16:51.866 INFO [139746086545152] ClientConnection:189 | [ -> pulsar://127.0.0.1:6650,127.0.0.2:6650] Create ClientConnection, timeout=10000
2023-04-25 14:16:51.866 INFO [139746086545152] ConnectionPool:96 | Created connection for pulsar://127.0.0.1:6650,127.0.0.2:6650
2023-04-25 14:16:51.867 WARN [139745917667072] ClientConnection:436 | [ -> pulsar://127.0.0.1:6650,127.0.0.2:6650] Failed to establish connection: Connection refused
2023-04-25 14:16:51.867 INFO [139745917667072] ClientConnection:1563 | [ -> pulsar://127.0.0.1:6650,127.0.0.2:6650] Connection closed
2023-04-25 14:16:51.867 ERROR [139745917667072] ClientImpl:190 | Error Checking/Getting Partition Metadata while creating producer on persistent://qlm-test/qlm-ns/python-test3 -- ConnectError
2023-04-25 14:16:51.867 INFO [139745917667072] ClientConnection:263 | [ -> pulsar://127.0.0.1:6650,127.0.0.2:6650] Destroyed connection
Traceback (most recent call last):
File "pulsar-test.py", line 8, in
producer = client.create_producer(
File "/usr/local/python3/lib/python3.8/site-packages/pulsar/__init__.py", line 603, in create_producer
p._producer = self._client.create_producer(topic, conf)
_pulsar.ConnectError: Pulsar error: ConnectError
2023-04-25 14:16:51.871 INFO [139745917667072] ExecutorService:47 | Event loop of ExecutorService exits successfully
```
**Expected behavior**
Within the timeout period, if the connection fails to be obtained, a retry is initiated
Such as the processing method of java client:
```
2023-04-25 14:18:45.078[pulsar-external-listener-3-1] WARN org.apache.pulsar.client.impl.PulsarClientImpl - [topic: persistent://qlm-test/qlm-ns/python-test3] Could not get connection while getPartitionedTopicMetadata -- Will try again in 6345 ms
2023-04-25 14:18:45.093[pulsar-client-io-1-1] INFO org.apache.pulsar.client.impl.ConnectionPool - [[id: 0xedb4eab7, L:/10.13.209.102:58831 - R:/10.101.129.65:6650]] Connected to server
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.