Pulsar "Failed to get partitioned topic metadata" in CI
Before producing or consuming, the Pulsar client looks up a topic to learn whether it is partitioned and which broker owns it. This lookup failed: the broker was not ready, the service URL was wrong, or the topic lookup timed out.
What this error means
The client fails with "Failed to get partitioned topic metadata: ... " often wrapping a lookup timeout or connection error during client setup.
org.apache.pulsar.client.api.PulsarClientException:
Failed to get partitioned topic metadata: java.util.concurrent.TimeoutExceptionCommon causes
The broker was not ready for lookups
The lookup to resolve topic ownership runs against a broker that has not finished startup, so it times out.
Wrong service URL for the lookup
A serviceUrl that does not match the broker binary address makes the lookup unreachable.
How to fix it
Wait for broker health before client setup
Gate client creation on the broker health admin endpoint so lookups succeed.
until curl -sf http://localhost:8080/admin/v2/brokers/health; do
echo "waiting for pulsar broker"; sleep 3
doneUse the correct binary serviceUrl
Point the client at the mapped 6650 address the broker advertises.
env:
PULSAR_SERVICE_URL: pulsar://localhost:6650How to prevent it
- Wait for the broker health endpoint before creating clients.
- Keep
serviceUrlaligned with the mapped binary port. - Allow a generous lookup timeout for slow first startup.